This blog post series is for all those who would like to kickstart and learn VMware PowerCLI from the very basic level. Let's start with installing the PowerCLI module.
Get-Module VMware.PowerCLI -ListAvailable
In this case, as shown above, VMware.PowerCLI module is not installed. Now let's find the latest version of the module available from PowerShell gallery.
Find-Module VMware.PowerCLI
11.2.0.12780525 is the latest version that is available in PSGallery.
To install this module use: Install-Module VMware.PowerCLI
Installation of this module may take a couple of minutes as this is the very first time. Once successfully installed you can verify using: Get-Module VMware.PowerCLI -ListAvailable
To list all the available cmdlets: Get-Command -Module VMware*
Now, let's go ahead and connect to an ESXi host.
Connect-VIServer <IP of ESXi server>
Provide the necessary credentials and once connected successfully you will see the below.
Few more useful details that are available under "ExtensionData" are given below.
There is a property called "RebootRequired" which actually shows whether there is any pending reboot for the system.
System uptime and resource utilization are available under "QuickStats" property.
Note:
"OverallCpuUsage" is in MHz, "OverallMemoryUsage" is in MB and "Uptime" is in Seconds.
List of all system capabilities: $h1.ExtensionData.Capability
BIOS version: $h1.ExtensionData.Hardware.BiosInfo
In the next article, we will discuss connecting to the vCenter server using PowerCLI and performing day-to-day operations. Hope this was useful. Cheers!
First, verify whether VMware.PowerCLI module is already installed on your machine.
Get-Module VMware.PowerCLI -ListAvailable
In this case, as shown above, VMware.PowerCLI module is not installed. Now let's find the latest version of the module available from PowerShell gallery.
Find-Module VMware.PowerCLI
11.2.0.12780525 is the latest version that is available in PSGallery.
To install this module use: Install-Module VMware.PowerCLI
Installation of this module may take a couple of minutes as this is the very first time. Once successfully installed you can verify using: Get-Module VMware.PowerCLI -ListAvailable
To list all the available cmdlets: Get-Command -Module VMware*
Now, let's go ahead and connect to an ESXi host.
Connect-VIServer <IP of ESXi server>
Provide the necessary credentials and once connected successfully you will see the below.
To get basic details of the ESXi host: Get-VMHost <IP of ESXi server>
To get more information about a cmdlet you can make use of the PowerShell Help System.
You can find all the properties and methods available for an object using: Get-Member
Example: Get-VMHost 192.168.105.1 | Get-Member
To retrieve specific properties of an ESXi host object:
$h1 = Get-VMHost 192.168.105.1
Model detail: $h1.Model
Processor type: $h1.ProcessorType
Another very useful property is "ExtensionData". Let's have a detailed look at this property.
This property provides you a lot of info regarding system runtime, hardware health status, etc.
System and hardware health status:
Memory and CPU health status:
Configuration status: $h1.ExtensionData.ConfigStatus
Configuration issues: $h1.ExtensionData.ConfigIssue
There is a property called "RebootRequired" which actually shows whether there is any pending reboot for the system.
System uptime and resource utilization are available under "QuickStats" property.
Note:
"OverallCpuUsage" is in MHz, "OverallMemoryUsage" is in MB and "Uptime" is in Seconds.
List of all system capabilities: $h1.ExtensionData.Capability
BIOS version: $h1.ExtensionData.Hardware.BiosInfo
In the next article, we will discuss connecting to the vCenter server using PowerCLI and performing day-to-day operations. Hope this was useful. Cheers!