Hello Everyone !
I'm looking for script that can list all the unmounted storage devices from the ESXi host,
Description : I have unmounted the vmfs volumes under datstores tab, detached the luns under devices tab, however these devices have not been unpresented from the SAN yet. Can anyone help with script to pull out the list of these unmounted devices on csv file. Some thing like in below format. and the script should prompt for cluster name. Thanks in advance.
cluster | esx host | NAAid |
Does this do the trick?
foreach($cluster in Get-Cluster){
foreach($esx in Get-VMHost -Location $cluster){
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.core.device.list.Invoke() |
where{$_.IsOffline} |
Select @{N='Cluster';E={$cluster.Name}},
@{N='VMHost';E={$esx.Name}}, Device
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
HI LucD
It lists the mounted LUNs as well, I am looking for something that lists only the unmounted LUNS
I tried below
&{foreach($cluster in Get-Cluster){
foreach($esx in Get-VMHost -Location $cluster){
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.core.device.list.Invoke() |
where{$_.IsOffline} |
Select @{N='Cluster';E={$cluster.Name}},
='VMHost';E={$esx.Name}}, Device
='Vendor';E={$scsilun.Vendor}}
| Export-Csv report.csv -NoTypeInformation -UseCulture
But I don't see vendor type in the output
This worked,
I believe
where{$_.IsOffline} is not valid value , I tried where{$_.Status -eq "off"} |, but thank you so much for all your help
&{foreach($cluster in Get-Cluster){
foreach($esx in Get-VMHost -Location $cluster){
$esxcli = Get-EsxCli -VMHost host.com -V2
$esxcli.storage.core.device.list.Invoke() |
where{$_.Status -eq "off"} |
Select @{N='Cluster';E={$cluster.Name}},
@{N='VMHost';E={$esx.Name}},
@{N='Vendor';E={$_.Vendor}}, Device, Status
}
}}| Export-Csv report.csv -NoTypeInformation -UseCulture
Glad you found it.
Yes, those flags are not too clear :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference