Thanks luc you got me pointed in the right direction. I was trying to determine how to get naa id from datstore name and after looking a the script you sent i got it figured out with this
$hostviewDSDiskName =$ds.ExtensionData.Info.vmfs.extent[0].Diskname So i took your function to fit my existing script i have that reads in datastores and hosts spreadsheet! hosts file just column with header "host" then hostnames and datastore list with title datastore
. .\detach-function.ps1 $vcenter = Read-Host "Enter Vcenter Name" Connect-VIServer $vcenter $hostslist = import-csv $list Disconnect-VIServer $vcenter -Confirm:$false
$list = read-host "Enter host list filename"
$datastorelist = import-csv datastores.csv
foreach ($vmhost in $hostslist){
$esx = Get-VMHost $vmhost.host
foreach ($ds in $datastorelist){
$datastore = Get-Datastore $ds.datastore
$naaid = $datastore.ExtensionData.Info.vmfs.extent[0].Diskname
Detach-disk -VMhost $esx -CanonicalName $naaid
}
}