With the help of some code by LucD on this forum, I wrote the following script to trigger the unmap on VMFS 5 volumes, but I keep getting a time out error after about 5 minutes. An unmap operation would usually take much longer and my guess is that in the background the unmap is still running. But this leaves me with the following questions:
- can I prevent the time out and have the script "hang" for hours until the unmap is finished?
- if above is not an option, can I start the command async so the script continues immediately?
- is there a powershell way to check for running unmap operations?
$Cluster = get-cluster | Out-GridView -Title "Select cluster" -PassThru
$esxName = $cluster | get-vmhost | Select-Object -First 1
$esxcli = Get-EsxCli -VMHost $esxName.name -V2
write-host "Start: $(get-date)"
ForEach( $datastoreName in ( $esxname | get-datastore | Out-GridView -Title "Select datastores" -PassThru ))
{
write-host "Start unmap of $datastorename at $(get-date)"
$sParam = @{volumelabel = $datastoreName}
$esxcli.storage.vmfs.unmap.Invoke($sParam)
}
write-host "Ready: $(get-date)"
Thank you
Try increasing or disabling the default timeout of 300 seconds with the Set-PowerCLIConfiguration cmdlet and the WebOperationsTimeout parameter.
Set-PowerCLIConfiguration -WebOperationTimeoutSeconds 600 -Confirm:$false
# Disable timeout
Set-PowerCLIConfiguration -WebOperationTimeoutSeconds -1 -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Setting the timeout to -1, gives me a time out at about half an hour :-s
That is unfortunately not the same timeout.
That is the session timeout, see KB2040626
You can make that change via an SSH session to the VCSA.
See my Use Posh-SSH instead of PuTTY post.
While the post is for an ESXi node, this also works for the VCSA
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hmmm, that would change the time-out for all connections. Not what I want to influence.
Is there a way to have the "$esxcli.storage.vmfs.unmap.invoke()" command return immediately? Like -async ?
I can then monitor progress on the ESXi host locally by checking for the file ".asyncUnmapFile".
I'm afraid not.
But you might want to try connecting to the ESXi node instead of the vCenter (with Connect-VIServer).
Then the vCenter timeout doesn't come into play afaik.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference