vSphere 5.1 Release Date leaked? (Updated)
VMware asked me to pull the post about the release date.
So I guess you all have to wait for VMware to release some more info (and not by accident like they did yesterday ).
List HA Runtime States with PowerCLI
The HA Agent on vSphere 4.x Hosts can be in several states:
– uninitialized
– initialized
– running
– error
– agentShutdown
– nodeFailed
If you have HA Enabled on your cluster, all states except running are basically not good and requires investigation.
These states can be fetched, but to my knowledge there is no easy cmdlet available to do so… so we’ll have to dig in the SDK.
Enable RSS in Guest OS with PowerCLI
If you have Windows 2003/2008 (R2) VMs with the VMXNet3 vNIC, you might want to enable RSS.
See the following article for more details and the improvements when enabling RSS.
Enable RSS (Receive Side Scaling) on Windows 2008 (R2) Virtual Machines
To enable RSS, you need to do some action inside the VM. Luckily, this can be scripted. Basically, we will invoke a batchfile from PowerCLI (through VMware Tools) to change a regkey which enables RSS. This can be easily adapted to loop through all VMs and enable it on all with VMXNet3 adapters.
Suppressing VMware VIX Warnings when running Invoke-VMScript cmdlets
I have a practice of running up-to-date software.
Some scripts in PowerCLI which perform in-guest operations, depend on VMware VIX.
The latest version of VIX is 1.10.1.12915.
Get all VMs with Fixed MAC Addresses using PowerCLI
I needed a list of all VMs with a Fixed MAC Address running on vSphere (it works for ESX 3.5 as well).
Let’s build up this command from the beginning. We start with Get-VM to get a hold of all VMs.
Get-VM
This of course will list just any VM. So we need some filtering.
Find VMs with Mismatched OS using PowerCLI
Almost every environment has one or more VMs where the running OS doesn’t match what is configured on the VM.
Let me explain:
Every VM has a property which contains the OS version:
This is usually set when you create the VM. In this example, the VM is set to Windows 7 x64. But if you install an OS in the VM, VMware is also aware of the Guest OS through VMware Tools. This is visible on the Summary page of the VM.
Both fields should match, but if you upgrade the OS inside the VM and forget to change the Settings of the VM, you have a mismatch.
How to Hard Kill a stuck VM with PowerCLI
Sometimes a VM is stuck and can’t be killed with vSphere Client (or from within the VM).
On ESX, you could login and perform the famous kill –9 <PID> to kill the VM. Most people don’t realize that this functionality has been added to PowerCLI in version 4.1 Update 1.
First, connect directly to the ESX(i) host.
Connect-VIServer -Server <Hostname> -Credential $(Get-Credential -Credential root)
PowerCLI: Convert PortWorldWideName or NodeWorldWideName to hexadecimal format.
If you output one of the fields of $VMHost.Config.StorageDevice.MultipathInfo.Lun[x].Path[x].Transport, you will get the output in standard decimal numbers.
This is different from what is used in SAN environment where they mostly use XX:XX:XX:XX:XX:XX:XX:XX where XX is a hexadecimal number.
Use the following code to convert from the decimal format to the hexadecimal SAN format:
[String] $lstrWWNNHex = "{0:x}" -f $NodeWorldWideName
[String] $lstrWWNNHexFormatted = ""
For ($i=0;$i -lt 8;$i++)
{
$lstrWWNNHexFormatted += "{0}:" -f $($lstrWWNNHex.SubString($i * 2, 2))
}
$lstrWWNNHexFormatted = $lstrWWNNHexFormatted.SubString(0, $lstrWWNNHexFormatted.Length - 1)
$NodeWorldWideName is the WWN generated by $VMHost.Config.StorageDevice.MultipathInfo.Lun[x].Path[x].Transport.NodeWorldWideName. You can use the same for PortWorldWideName.
How to check if PowerCLI libraries are loaded in PowerShell/PowerGUI
If you write scripts in PowerShell or PowerGUI, it might be handy to check if the PowerCLI libraries are loaded.
Even though you have PowerCLI installed, this does not mean the objects are loaded in your PowerShell session.
In PowerGUI for example, you can check this by clicking File – PowerShell Libraries.
Check HP Management Agents with PowerCLI
Checking on the existence of HP Management Agents on your ESX hosts and/or their version is rather easy with PowerCLI.
Connect to your vCenter hosts using the Connect-VIServer cmdlet (remember that you can connect to multiple servers!).