Monday, 16 February 2015

Combining PowerCLI & ESXCLI to change PSP on a Large Scale

Using PowerCLI you can use Set-ScsiLun -MultipathPolicy "RoundRobin" to set the PSP, but I found it quite slow using it on a large scale. It would update one datastore on one host every 5 seconds. If there were 10 ESXi hosts with 200 Datastores, that's 2000 operations, at 5 seconds each, it adds up to 3 hours. The same can be done using ESXCLI extremely quickly, but it's run on each host. If only there was a way to combine PowerCLI and ESXCLI.

There is... Get-EsxCli

A quick and dirty script that combines PowerCLI & ESXCLI to change the PSP on multiple hosts & datastores.

Use at your own risk. This will change the PSP to RoundRobin for any non local device.

Get existing PSP to see how many you need to change:
1:  $AllESXHosts = Get-Cluster CLUSTERNAME | Get-VMHost | Where { ($_.ConnectionState -eq "Connected") -or ($_.ConnectionState -eq "Maintenance")} | Sort Name   
2:  ForEach ($esxhost in $AllESXHosts) {  
3:    Get-VMhost $esxhost | Get-ScsiLun -LunType disk | Where { $_.MultipathPolicy -notlike "RoundRobin" } |Where {$_.IsLocal -notlike "True"} | Select CanonicalName,MultipathPolicy,IsLocal |ft -autosize  
4:  }  

Set PSP:
1:  $AllESXHosts = Get-Cluster CLUSTERNAME |Get-VMHost | Where { ($_.ConnectionState -eq "Connected") -or ($_.ConnectionState -eq "Maintenance")} | Sort Name   
2:  ForEach ($esxhost in $AllESXHosts) {  
3:    $esxcli = Get-EsxCli -VMHost $esxhost  
4:    $targetdevice = Get-VMhost $esxhost | Get-ScsiLun -LunType disk | Where { $_.MultipathPolicy -notlike "RoundRobin" } |Where {$_.IsLocal -notlike "True"}   
5:    ForEach ($device in $targetdevice) {  
6:      Write-Host "Updating $ $device.CanonicalName"  
7:      $$null,$device,"VMW_PSP_RR")  
8:    }  
9:   }  

 For a more cautious approach, try one host at a time:
1: $esxcli = Get-EsxCli -VMHost $esxhost
2: Get-VMhost $esxhost | Get-ScsiLun -LunType disk | Where { $_.MultipathPolicy -notlike "RoundRobin" } |Where {$_.IsLocal -notlike "True"} | $$null,$device,"VMW_PSP_RR")  

Run the script to get PSP again to confirm it worked.

The interesting thing is there's no logs of the changes happening in vCenter when using esxcli as opposed to Set-ScsiLun,and ssh is NOT enabled, so it's still using your vCenter credentials.

So you don't have to go through this process again, remember to set the default PSP on each host, or use Host Profiles!!:
esxcli storage nmp satp set --default-psp=policy --satp=your_SATP_name 

Disclaimer: I'm pretty terrible with PowerCLI, so this must look pretty ugly. I'm sure there's better ways to do it, but it gets the job done.

Monday, 9 February 2015

2015 Australian / New Zealand vExperts

VMware announced the list of 2015 vExperts during the week. Congratulations to all that made it. The list now contains over 1,000 vExperts.

For something perhaps a bit more relevant in the A/NZ region, I've broken it down for us.

The numbers haven't changed that much due to the 3 selection rounds of vExperts in 2014.

For the A/NZ region, the numbers increased by 3, with 4 people not renewed as vExperts (most likely because they didn't submit an entry). Melbourne still holds as a clear winner with the most active VMware community, but I'm sure the other regions will gain momentum this year.

New Zealand has the most potential, with lots of talented guys there, so hopefully with the launch of the Auckland VMUG, they'll see an increase in activity.

And Perth.. We'll give them the encouragement award 2014. C'mon guys, you can do it. 

Melbourne: 17

Sydney: 6
New Zealand: 5
Brisbane: 4
Perth: 3

If there's anyone I've missed, let me know.

If you're interested in seeing what some of the people in the list above do, check out for links to each of their blogs.