Previous admin incorrectly set perennially-resevered to true on VMFS volume. I am seeing roughly 60 ESXi hosts attached to those datastores.
Can anyone share script for identify and correct them[set perennially-reserved to false] on these datastores with such ?
Thanks.
You could try something like this
$dsName = 'MyDS'
$ds = Get-Datastore -Name $dsName
$luns = Get-ScsiLun -Datastore $ds | Select -ExpandProperty CanonicalName
Get-VMHost -Datastore $ds |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $_ -V2
$esxcli.storage.core.device.list.Invoke() | where{$luns -contains $_.Device} | %{
$params = @{
device = $_.Device
perenniallyreserved = $false
}
$esxcli.storage.core.device.setconfig.Invoke($params)
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Would this change all the DSs on all the ESXi hosts that have this currently set to true? There are numerous DSs connected to numerous ESXi hosts that need this to be changed to false.
No, the script doesn't first check if the setting is true.
It just sets all LUNs for a specific datastore on all ESXi nodes that know this datastore to false.
You could include a test.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Would it skip any RDMs that might be in use? I only want to change the setting to false on VMFS DSs (LUNs)
It will only handle the LUNs that make up the Datastore
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank you!
I tried the script with a wildcard but that did not work. I needed to input each datastore individually. We have numerous datastores that need to be changed and would like to use the wildcard. I changed the first line in the script to $dsName -Like 'YourDatastore*' however the -Like cmdlet is not valid. Does anyone know what the cmd would be to use a wildscard?
You will have to loop through all the Datastores.
Each datastore has different LUNs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference