Hi,
I am trying to disable Perennially Reserve on all devices in Cluster
But it is not working.
Please help.
$esxis = get-cluster MyClus | get-vmhost
foreach ($vmhost in $esxis){
$myesxcli = Get-EsxCli -VMHost $vmhost
$diskinfo = $myesxcli.storage.core.device.list() | Select -ExpandProperty IsPerenniallyReserved
"$($vmhost.Name) $($rdm.Canonical_Name) IsPerenniallyReserved= $($diskinfo)"
if($diskinfo -eq "true")
{
write-host "Configuring Perennial Reservation for LUN " $_.Device ":" $myesxcli.storage.core.device.setconfig($false,$_.Device,$false)
$diskinfo = $myesxcli.storage.core.device.list() | Select -ExpandProperty IsPerenniallyReserved
"$($vmhost.Name) $($_.Device) IsPerenniallyReserved= $($diskinfo)"
"----------------"
}
}
You have to do this device by device.
Something like this for example
Get-Cluster | Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$myesxcli = Get-EsxCli -VMHost $esx -V2
$myesxcli.storage.core.device.list.Invoke() |
ForEach-Object -Process {
Write-Host "$($vmhost.Name) $($_.Device) IsPerenniallyReserved= $($_.IsPerenniallyReserved)"
if($_.IsPerenniallyReserved){
Write-Host "Configuring Perennial Reservation for LUN: $($_.Device)"
$myesxcli.storage.core.device.setconfig.Invoke(@{device=$_.Device;perenniallyreserved=$false})
Write-Host "$($vmhost.Name) $($_.Device) IsPerenniallyReserved= $($_.IsPerenniallyReserved)"
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You have to do this device by device.
Something like this for example
Get-Cluster | Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$myesxcli = Get-EsxCli -VMHost $esx -V2
$myesxcli.storage.core.device.list.Invoke() |
ForEach-Object -Process {
Write-Host "$($vmhost.Name) $($_.Device) IsPerenniallyReserved= $($_.IsPerenniallyReserved)"
if($_.IsPerenniallyReserved){
Write-Host "Configuring Perennial Reservation for LUN: $($_.Device)"
$myesxcli.storage.core.device.setconfig.Invoke(@{device=$_.Device;perenniallyreserved=$false})
Write-Host "$($vmhost.Name) $($_.Device) IsPerenniallyReserved= $($_.IsPerenniallyReserved)"
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked perfectly. Thank you very much 🙂