Moving VMs between Port Groups

I’m currently running a project to consolidate a sprawl of VM farms which are underutilised, down to a much smaller number, and a significant reduction in host numbers. The first cluster I’ve started work on had a non-standard naming convention for the Port Groups, so prior to moving this needs correcting.

First I’ve added new Port groups with the correct names, then I knocked up a quick PowerCLI script to move all the VMs:

$vms = Get-Cluster "Cluster1" | Get-VM
foreach ($vm in $vms) {
$nics = $vm | Get-NetworkAdapter
 foreach ($nic in $nics) {
 if ( $nic.NetworkName -eq "1st_old_name") {
  Set-NetworkAdapter $nic -NetworkName "1st_new_name" -Confirm:$false
 if ( $nic.NetworkName -eq "2nd_old_name") {
  Set-NetworkAdapter $nic -NetworkName "2nd_new_name" -Confirm:$false

This cycles through each of the VMs in the cluster, and moves each adapter on the old name to the new name.


Script to check for single paths and dead paths

Here we are, script amended to report only on single paths and dead paths for scsi luns

$initalTime = Get-Date
$filepath = "C:tmp"
$filename = "LunPathState"
$date = Get-Date ($initalTime) -uformat %Y%m%d
$time = Get-Date ($initalTime) -uformat %H%M

$AllHosts = Get-VMHost | Sort Name

$reportLunPathState = @()

$i = 0

ForEach ($VMHost in $AllHosts) {
Write-Host "$(Get-Date -uformat %H:%M:%S) - $($i) of $($AllHosts.length) - $($VMHost)"
$VMHostScsiLuns = $VMHost | Get-ScsiLun -LunType disk
ForEach ($VMHostScsiLun in $VMHostScsiLuns) {
$VMHostScsiLunPaths = $VMHostScsiLun | Get-ScsiLunPath
If ((($VMHostScsiLunPaths | Measure-Object).Count -eq 1 )) {
$reportLunPathState += ($VMHostScsiLunPaths | Measure-Object) | Select @{N="Hostname"; E={$VMHost.Name}}, @{N="Number of Paths"; E={$_.Count}}, Name, State
$reportLunPathState += $VMHostScsiLunPaths | Select @{N="Hostname"; E={$VMHost.Name}}, "Number of Paths", Name, State
ForEach ($VMHostScsiLunPath in $VMHostScsiLunPaths) {
If ($VMHostScsiLunPath.State -eq "Dead") {
$reportLunPathState += ($VMHostScsiLunPath | Measure-Object) | Select @{N="Hostname"; E={$VMHost.Name}}, @{N="Number of Paths"; E={$_.Count}}, Name, State
$reportLunPathState += $VMHostScsiLunPath | Select @{N="Hostname"; E={$VMHost.Name}}, "Number of Paths", Name, State
if ($i -eq 2) {break}

$reportLunPathState | Out-GridView
$reportLunPathState | Export-Csv $filepath$date$time"-"$filename".csv" -NoType

Checking VMware…

Checking VMware host storage path redundancy

I was asked yesterday whether we had any scripts to check host storage path redundancy, and while we do, it is something that was written for ESX 3.5, and hasn’t been updated for anything more recent.

Looking around there are some scripts to do similar things but I couldn’t find anything that did exactly what I was after.

I’m going to look at build something, hopefully on the lines of this script

VCAP/VCDX bootcamp review

Yesterday was spent at VMware’s UK offices in Frimley – not the easiest place to get to from the North of England, but the same goes for much of the tech corridor around the M3/M4.

The day was lead by John Arrasjid (@vxcd001) and Mostafa Khalil (@MostafaVMW), and consisted of presentations about preparing for the VCAP-DCA/CIA/DTA, the VCAP-DCD/CID/DTD, and the VCDX-DCV/Cloud/DT

Members of the audience had a relatively wide range of experience and backgrounds, Admins, Architects, those with just VCP, through to those about to defend their VCDX design submission.

The first presentation was on the VCAP administration track, and the volume of questions from the participants led to this running over time by about an hour and a half!

The second presentation on the VCAP design track was skipped through in about an hour, and was of more imminent relevance to me as it’s the next exam I need to prepare for.

A slightly extended lunch break followed, then it was on to the VCDX section. This was very eye-opening, and I guess the main thrust of the day. There were a lot of useful hints and tips for how to approach the certification, with plenty of suggestions about what *not* to do!

Much of the material that was covered is available on the web under the following links:

VCAP Administration Track

VCAP Design Part 1

VCAP Design Part 2


If you get the chance to attend the bootcamp, you should definitely go for it, and John made it clear how much difference it made to the success of VCDX defences with a number of statistics on pass rates.

VCDX first steps

I have been fortunate enough to be chosen for an internal company initiative to sponsor a number of people through the VCDX process.

Today I am travelling with Darryl Cauldwell (@potato_heads) to Farnborough, ready for a VCAP/VCDX bootcamp tomorrow at VMware’s offices in Frimley.

John Arrasjid ‏ (@vcdx001) is running the course, and we’re both very much looking forward to meeting him.

Beginning in blogging

Inspired by Darryl Cauldwell (@potato_heads) I have decided to start blogging my vmware experiences. Not sure yet how often I’ll be adding to the blog, but I’m hoping to do at least one per month.