## esxcli storage core device detached list
# Script variables
# Add-PSSnapin vmWARE.VimAutomation.Core
# $vcenter = "vcenter01"
$LunIDs = ("naa.60000970000498700406544040444047", "naa.60000970000498700406544040444048")
$mycluster = "cluster01"
# Connect to Vcenter
# Connect-VIServer $vcenter
## $SourceNaa = "C:\cPS\TEST\unmount_detach_datastore\NaaList.txt"
## $LunIDs = Get-Content $SourceNaa
## $mycluster = "cluster01"
function Detach-Disk {
param(
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl]$VMHost,
[string]$CanonicalName )
$storSys = Get-View $VMHost.Extensiondata.ConfigManager.StorageSystem
$lunUuid = (Get-ScsiLun -VmHost $VMHost | where {$_.CanonicalName -eq $CanonicalName}).ExtensionData.Uuid
$storSys.DetachScsiLun($lunUuid)
}
$ClusterHosts = Get-Cluster $mycluster | Get-VMHost
Foreach($VMHost in $ClusterHosts)
{
Foreach($LUNid in $LunIDs)
{
Write-Host "Detaching" $LUNid "from" $VMHost -ForegroundColor "Yellow"
Detach-Disk -VMHost $VMHost -CanonicalName $LUNid
}
}
附件:http://down.51cto.com/data/2368727
本文转自学海无涯博客51CTO博客,原文链接http://blog.51cto.com/549687/1980213如需转载请自行联系原作者
520feng2007