Hi all,
I have a powershell script which works perfectly to retrieve all VMWare host disk values which I require specifically for the setting of their Perennial values
I now have been asked to add the datastore which the disk resides in which I thought would be an easy task however it is not listed in any of the current disk context I am using
I could use the get-datastore cmdlet earlier on in the script however I cannot see anything which ties the datastore to the disk?
Anyone know of how I might be able to do this
$Cred = get-credential -UserName Username -Message 'Enter Password for vCenter Servers' $VCs = get-content .\VCenterServers.txt foreach ($VC in $VCs) { write-host 'Connecting to vCenter Server'$VC -ForegroundColor Green Connect-VIServer -server $VC -Credential $Cred $Clusters = Get-Cluster foreach ($Cluster in $Clusters) { $Clushosts = $Cluster | get-vmhost foreach ($Clushost in $Clushosts) { write-host 'Getting disk information from ESXi Host' $Clushost $myesxcli = get-esxcli -VMHost $Clushost $HostDisks = $myesxcli.storage.core.device.list() $HostLun = $myesxcli.storage.core.path.list() foreach ($hostDisk in $HostDisks) { foreach ($Disk in $HostDisk) { $LunRaw = $hostlun | Where-Object { $_.device -eq $Disk.Device } | select -first 1 $Lun = $LunRaw | select -ExpandProperty lun $Results = [PScustomObject] @{ "vCenter Server" = $VC "Cluster" = $Cluster "ESXi Host" = $Clushost "Device" = $Disk.Device "Device Type" = $Disk.DeviceType "IsPerenniallyReserved" = $Disk.IsPerenniallyReserved "Is RDM Capable" = $Disk.IsRDMCapable "Vendor" = $Disk.Vendor "LUN" = $Lun } } $Results | export-csv LatestPerrenialReservations2.csv -NoTypeInformation -Append } } } write-host 'Disconnecting from'$VC -ForegroundColor White Disconnect-VIServer -Server $VC -Confirm:$False }
Many thanks in advance!