VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot

Need help in VMFS and RDM Report

Hi All,

I would looking for similar output from a Powershell script. I am a newbie to Scripting. Please help.

pastedImage_0.png

Below is the script that I have and needs your help in getting the above format output.

$report = @()  

$vms = Get-VM windows1 | Get-View

foreach ($vm in $vms)

    foreach($dev in $vm.Config.Hardware.Device){ 

        if(($dev.gettype()).Name -eq "VirtualDisk"){ 

            if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or ($dev.Backing.CompatibilityMode -eq "virtualMode")){ 

                $row = "" | select VMName, VMHost, HDDeviceName, HDMode, HDsize, HDDisplayName, LUN, HDName, HDFileName 

                $row = "" | select VMHost, VMName, HDName, LUN, HDsize, HDMode, HDDisplayName

                $row.VMName = $vm.Name 

                $esx = Get-View $vm.Runtime.Host 

                $row.VMHost = ($esx).Name 

                $row.HDName = $dev.DeviceInfo.Label               

                $row.HDMode = $dev.Backing.CompatibilityMode 

                $row.HDSize = [system.math]::Round($dev.CapacityInKB / 1048576)

                $row.HDDisplayName = ($esx.Config.StorageDevice.ScsiLun | where {$_.Uuid -eq $dev.Backing.LunUuid}).CanonicalName 

                $lun = Get-ScsiLun -VmHost $row.VMHost -CanonicalName $row.HDDisplayName 

                $row.LUN = $lun.RuntimeName.SubString($lun.RuntimeName.LastIndexof("L")+1) 

                $report += $row 

            } 

         } 

    } 

Tags (1)
0 Kudos
4 Replies
ganapa2000
Hot Shot
Hot Shot

Hi All,

The above script shows only the below parameters

VMHost

VMName

HDMode

HDName

HDsize

LUN

HDDisplayName

Now, I would like to add

Cluster Name

VM IP Address

VM Folder Name

VMFS

Please help, I am newbie to scripting world.

0 Kudos
Wh33ly
Hot Shot
Hot Shot

I added the options below

#Cluster Name

#VM IP Address

#VM Folder Name

I removed the $row = "" which was there twice ?? with different selects

What do you mean with the part VMFS ? What kind of information are you looking for

$report = @() 

$vms = Get-VM <VM>| Get-View

foreach ($vm in $vms)

{

    foreach($dev in $vm.Config.Hardware.Device){

        if(($dev.gettype()).Name -eq "VirtualDisk"){

            if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or ($dev.Backing.CompatibilityMode -eq "virtualMode")){

                $row = "" | select VMHost, VMName, HDName, LUN, HDsize, HDMode, HDDisplayName, IP, Cluster,Folder

                $row.VMName = $vm.Name

                $esx = Get-View $vm.Runtime.Host

                $row.VMHost = ($esx).Name

                $row.HDName = $dev.DeviceInfo.Label              

                $row.HDMode = $dev.Backing.CompatibilityMode

                $row.HDSize = [system.math]::Round($dev.CapacityInKB / 1048576)

                $row.HDDisplayName = ($esx.Config.StorageDevice.ScsiLun | where {$_.Uuid -eq $dev.Backing.LunUuid}).CanonicalName

                $lun = Get-ScsiLun -VmHost $row.VMHost -CanonicalName $row.HDDisplayName

                $row.LUN = $lun.RuntimeName.SubString($lun.RuntimeName.LastIndexof("L")+1)

                $row.IP = $vm.guest.IpAddress

                $row.Cluster = (get-view -ViewType clustercomputeresource | ?{$_.moref -match $esx.parent.value}).name

                $row.Folder = (get-view -ViewType Folder | ?{$_.moref -match $vm.parent.value}).name

                $report += $row

            }

         }

    }

}  $report|ft -a

0 Kudos
ganapa2000
Hot Shot
Hot Shot

Hi,

Thanks for your reply,

I am also want to VMDK details to this script. Now, I am able to get only RDM details, but I want VMDK details with below example.

pastedImage_1.png

0 Kudos
ganapa2000
Hot Shot
Hot Shot

Please, someone help on this script.

0 Kudos