PowerCli – Check and change Advanced VM settings – disk.enableUUID

Added menu stuff:

http://stackoverflow.com/questions/1785474/get-index-of-current-item-in-powershell-loop

http://blogs.technet.com/b/heyscriptingguy/archive/2008/06/02/hey-scripting-guy-how-can-i-use-leading-zeroes-when-displaying-a-value-in-windows-powershell.aspx

https://www.novell.com/support/kb/doc.php?id=7002966

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2006865

+++++++++++++ POWERCLI SCRIPT +++++++++++++++

# Autor: AA
# Datum: 05.10.15

get-cluster | select Name | sort
$CLName = Read-Host “Type the exact name of the Cluster to be checked/set for disk.enableUUID”

$vms=get-cluster $CLName | get-vm | where {$_.Guest.OSFullName -match “Linux*” } | sort name

$vmscount=($vms).count

echo ” ==================================================== “
echo “Total Linux VMs found: $vmscount “
foreach ($vm in $vms) {

$vm_UUID_enable_check = get-vm $vm | Get-AdvancedSetting -Name disk.enableUUID | select Value | ft -HideTableHeaders
if ($vm_UUID_enable_check) {
if((get-vm $vm | Get-AdvancedSetting -Name disk.enableUUID).Value -ne “true”){
$vm | Get-AdvancedSetting -Name ‘disk.enableUUID’ | Set-AdvancedSetting -Value ‘true’ -Confirm:$false
write-host “=== Limux VM – $vm : CHANGED ADVANCED SETTING disk.enableUUID to true ==================”
}
else{
write-host “================= CHECKING disk.enableUUID on Linux VM – $vm : true ================”
}
}
else{
write-host “===== $vm : NEW ADVANCED SETTING disk.enableUUID = true ===================”
$vm | New-AdvancedSetting -Name ‘disk.enableUUID’ -Value ‘true’ -Confirm:$false
}

}