VMware Cloud Community
esxi1979
Expert
Expert

Get VM details : VM datastore, type(NFS) , vServer or NFS server ip

   foreach ($vm in (get-vm)) { 

     $props = @{'VMName'=$vm.Name; 

           'IP Address'= $vm.Guest.IPAddress[0];

           'PowerState'= $vm.PowerState; 

           'Domain Name'= ($vm.ExtensionData.Guest.Hostname -split '\.')[1,2] -join '.';           

           'vCPU'= $vm.NumCpu; 

           'RAM(GB)'= $vm.MemoryGB; 

           'Total-HDD(GB)'= $vm.ProvisionedSpaceGB -as [int]; 

           'HDDs(GB)'= ($vm | get-harddisk | select-object -ExpandProperty CapacityGB) -join " + "           

           'Datastore'= (Get-Datastore -vm $vm) -split ", " -join ", "; 

Is it possible to find the Netapp vServer ip (NFS server ip)  as well in above ?

Get-Datastore -vm XXX does shows

RemoteHostRemotePathUserNameAuthenticationMethodFileSystemVersionDatacenterIdDatacenterParentFolderIdParentFolderDatastoreBrowserPathFreeSpaceMBCapacityMBAccessibleTypeStorageIOControlEnabledCongestionThresholdMillisecondStateExtensionDataCapacityGBFreeSpaceGBNameIdUidClient

but the remote host ip does not seen even in normal export

3 Replies
vXav
Expert
Expert

Hi,

$NFSDatastoreIP = (Get-datastore "MyNfsDatastore").ExtensionData.info.nas.remotehost

esxi1979
Expert
Expert

I modified it a bit

'vServer' = (Get-datastore -vm $vm).ExtensionData.info.nas.remotehost

it does not give info when vm has 2 Data Stores tho, then it shows

System.Object[]
0 Kudos
vXav
Expert
Expert

I don't have anything to try but what comes to my mind just now would be :

$vServer = (Get-datastore -vm $vm) | foreach-object {$_.ExtensionData.info.nas.remotehost}

If you're querying several VMs that have the same datastores you might want to add select unique to avoid getting multiple occurences

$vServer = (Get-datastore -vm $vm) | foreach-object {$_.ExtensionData.info.nas.remotehost} | select -unique

0 Kudos