Category Archives: Powershell

Viewing VM CPU Masks via PowerCLI

This post was updated on 9th May 2017 to fix an error condition in the script. Support for Windows Server 2012 was announced starting with ESXi 5.0 Update 2, but there was a little known flaw in this support – in that without a CPU mask, a VM could blue screen at any time. The… Read More »

PowerCLI: Datastore Block Sizes

Before VMFS5 the block size of the datastore determined the maximum size of a hard disk that could be added to a virtual machine. In our new glorious future it now makes no difference, but VMFS datastores that have been upgraded to version 5 will retain their old block size. The following PowerCLI will show… Read More »

Powershell: Getting a list of VM adapter types

The following code will list the VMs which have network adapters that are not VMXNET3. This is useful for knowing what you likely have to change 😉 It will output the Name of the VM, the Type of adapter and the Network (i.e. Virtual Machine Portgroup) that it is connected to. The code will examine… Read More »

Getting a NetApp volume size with Powershell

I ran into a problem recently where I needed to get the size of a volume from a NetApp filer so I could create a new volume (of the same size) and initialise a snapmirror relationship to it. The problem was that sometimes the snapmirror relationship would fail to start, reporting that the destination volume… Read More »

Importing UCS VLANs

I’ve had to deal with two UCS systems recently, ensuring that the configuration matches on them both, most of which I was happy to go through by hand. But the long list of VLANs was another story. I could see that they can be exported, but I couldn’t find an import ability. So, a quick… Read More »

Listing Virtual Machines and Portgroups

vSphere 5.0 – If you need a list of Virtual Machines and the portgroups they are attached to:

If you need to export this to a CSV:

Getting a vSphere VM’s Network Adapters

Getting all the network adapters for a VM is an easy task:

When you remove a network adapter, vSphere will remove it’s entry in the .vmx file. In the .vmx file, the adapter configuration options are prepended by an “ethernetX” string, where X is a number between 0 and 9. Removing the adapter, removes… Read More »

Swapfile Datastores

If you have more than one swap file datastore for your hosts, then you might want to see which hosts are connected to what datastores.

Quick PowerCLI #1

I may or may not make this a series 😉 PowerShell with VMware is very useful. Ignoring the Connect-VIServer and Disconnect-VIServer commands, here are some tips. Getting the Swap File Datastore for all hosts in a cluster If you store VM swap files away from the VM folder (faster disk I would hope) and have… Read More »