The supported way to remove a LUN from VMware is to unmount and detach before removing your zoning. Problem is the unmount is easy as they provided a GUI option to do that one. But the detach has to be done on each hosts adapter, there is no easy button. PowerCLI to the rescue! This script will run through each host in a specified cluster and detach it.
Connect-VIServer vcenter.domain.com
$LunIDs = “naa.xxxxxxxxxxxxxx”
$Clustername = “clustername”
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 $Clustername | Get-VMHost
Foreach($VMHost in $ClusterHosts)
{
Foreach($LUNidin$LunIDs)
{
Write-Host”Detaching”$LUNid”from”$VMHost-ForegroundColor “Yellow”
Detach-Disk -VMHost $VMHost -CanonicalName $LUNid
}
}