Hi all,
I know this is old hat stuff as I saw an earlier blog which revolved around what I am trying to achieve here
So, I am trying to retrieve all RDM perennially reserved values per host per vcenter server
I think I have managed to make the script work in regards to it pulling the RawPhysical and RawVirtual disktype per vm and grab the unique values of these and then export these values to a .csv file
I have been asked however if I can also retrieve the LUN of each RDM, I have looked into how to get the LUN value however cannot see how I can place that within my current script
$Results = @() $VCenters = get-content VCenterServers.txt $Cred = get-credential -UserName mjclark_a@computacenter.com -Message 'Enter Password for vCenter Servers' foreach ($VC in $VCenters){ Write-Host 'Connecting to Vcenter Server '$VC -ForegroundColor Green Connect-VIServer -server $VC -Credential $Cred $dCenter = Get-Datacenter $Clusters = Get-Cluster foreach ($Cluster in $Clusters){ $clusterInfo = Get-Datacenter -Name $dCenter | get-cluster $cluster $vmHosts = $clusterInfo | get-vmhost | select -ExpandProperty Name $RDMNAAs = $clusterInfo | Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select -ExpandProperty ScsiCanonicalName -Unique foreach ($vmhost in $vmHosts) { $myesxcli = Get-EsxCli -VMHost $vmhost foreach ($naa in $RDMNAAs) { $diskinfo = $myesxcli.storage.core.device.list("$naa") | Select -ExpandProperty IsPerenniallyReserved $vmhost + " " + $naa + " " + "IsPerenniallyReserved= " + $diskinfo $RDMInfo = $vmhost + " " + $naa + " " + "IsPerenniallyReserved= " + $diskinfo if($diskinfo -eq "false") { write-host "Configuring Perennial Reservation for LUN $naa......." #$myesxcli.storage.core.device.setconfig($false,$naa,$true) $diskinfo = $myesxcli.storage.core.device.list("$naa") | Select -ExpandProperty IsPerenniallyReserved $vmhost + " " + $naa + " " + "IsPerenniallyReserved= " + $diskinfo $Results1 = [pscustomObject] @{ "vCenterServer" = $VC "Cluster" = $Cluster "VMHost" = $vmHost "DiskInfo" = $RDMInfo} } $Results += $Results1 write-host "----------------------------------------------------------------------------------------------" } } } write-host 'Disconnecting from vCenter Server '$VC -ForegroundColor Cyan Disconnect-VIServer $VC -confirm:$false } $Results | export-csv perrennialResults.csv -NoTypeInformation
basically as well as the raw naa ref ID I also would like the LUNid decimal value stored in vcenter
I think the command to do this is something along the lines below,
get-scsilun -vmhost *.vmhost -canonicalname *.hddisplayname
.runtimename.substring(.runtimename.lastindexof(āLā)+1)
This I borrowed from a previous article:
https://communities.vmware.com/thread/514090
Many thanks in advance!