PowerShell is a tool that sysadmins can use to manage tasks such as setting up tasks, managing Active Directory users, managing Exchange Online, and many other tasks.
PowerShell offers many modules that allow us to manage these resources, and make our lives easier through automation and efficiency. Your PowerShell journey will eventually lead you to realize that you can use a lot of the knowledge you already have about PowerShell to manage your VMware environment.
Use PowerCLI to inventory your infrastructure
Easy update VMware Tools
Schedule scripts can be run
PowerCLI could be the next tool in your administration arsenal. Here’s how you can get started.
What is PowerCLI?
PowerCLI is a set of PowerShell modules that allows you to manage a variety of VMware products. VMware PowerCLI comes with hundreds of cmdlets that allow you to manage your infrastructure globally, including managing and automating vSphere and vCloud environments. PowerCLI version 1.0.0 was released in the summer 2008 with 120 cmdlets. Version 12, which was released in April 2020, boasts more than 700 cmdlets!
Learn how to become a security expert with SPOTO’s Cybersecurity Training
Start trainingThe creators PowerCLI deliberately designed the resource to be an extension of PowerShell’s foundation. The easy-to-remember verb/noun syntax makes it much easier to learn PowerShell. Let’s learn a bit more about what it can do and give you some examples to try out in your environment. This article will focus on a standard VMware cluster, and how it interacts with guest VMs within.
How to get started with PowerCLI
You will need to add PowerCLI to your PowerShell arsenal in order to get started. The Get-Vm cmdlet will not work for you if this is the case. As a field guide, I recommend using the VMware Docs resource to install the module. This module can be installed on your vCenter Server instance, or on your personal workstation.
PowerCLI versions older than 6.x or earlier must be removed from the traditional Programs & Features area of your Windows machine. You will need to be connected to the Internet to pull the module from an online repository. If you are using Windows 7/8/Server 2012 R2 and earlier OSes, ensure Windows Management Framework 5.1 has been installed.
As an administrator, open a PowerShell window and enter:
You might be asked to install NuGet, a dependency that is often used to identify vulnerabilities, or to install from an untrusted repository. These are valid if you confirm with a “Y”.
You might also consider changing the local script policy of your station. You can make this setting as appropriate for your environment.
Remotely Signed Set-ExecutionPolicy
This command will opt out of the Customer Experience Improvement Program. It will also ignore any certificate warnings when PowerCLI is used. It’s a bonus to know PowerCLI provides additional security for organizations that rely heavily on internal certificates to keep their Security Operations staff happy.
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false -ParticipateInCeip $false
If you have previously installed PowerCLI, but feel it might need updating, you can use this link to check the version or update it.
Get-Module -Name VMware.PowerCLI -ListAvailable
Update-Module -Name VMware.PowerCLI
Now, PowerCLI’s latest version is up and running. You are now ready to look behind the clunky vCenter interface to really understand your environment. You will need to connect to your cluster via the FQDN.
Connect-VIServer -Server “cbt1