VMware Cloud Community
MehdiF
Enthusiast
Enthusiast
Jump to solution

Display number of LUN

Hello,

I would like display the LunID in my script but i dont make this. My script is : 

-------------------------------------------------------------------------------------------------------------------------------------

$VMS = Get-VM -Name "MyVM" | get-HardDisk -DiskType "RawPhysical", "RawVirtual"

$report = @()

foreach ($vm in $VMS) {

$row = "" | select Parent, DiskType, ScsiCanonicalName, Persistence, Filename,"LunID", CapacityGB

$row.Parent = $vm.Parent

$row.Disktype = $vm.disktype

$row.scsiCanonicalName = $vm.ScsiCanonicalName

$row.Persistence = $vm.Persistence

$row.Filename = $vm.Filename

$row."LunID" = ''

$row.CapacityGB = $vm.CapacityGB

$report += $row

}

 

$report | export-csv -Path "Path" -NoTypeInformation -UseCulture

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

VM                       DiskType                    LunName             Datastore                       Lunid                                                            Size

My VM                RawPhyscial               naa.xxxxxx           DatastoreName            Number of LUN (Exemple : 5)                   XGB

 

Thank you very much for help

 

Mehdi

$VMS = Get-VM -Name XS20792* | get-HardDisk -DiskType "RawPhysical", "RawVirtual"
 
$report = @()
foreach ($vm in $VMS) {
$row = "" | select Parent, DiskType, ScsiCanonicalName, Persistence, Filename,"LunID", CapacityGB
$row.Parent = $vm.Parent
$row.Disktype = $vm.disktype
$row.scsiCanonicalName = $vm.ScsiCanonicalName
$row.Persistence = $vm.Persistence
$row.Filename = $vm.Filename
$row."LunID" = ''
$row.CapacityGB = $vm.CapacityGB
$report += $row
}
 
$report | export-csv -Path "c:\mehdi\scripts_test\DiskType.csv" -NoTypeInformation -UseCulture
0 Kudos
1 Solution

Accepted Solutions
MehdiF
Enthusiast
Enthusiast
Jump to solution

hello LucD,

It's Perfect. Thank you very much 😉 

I will delete this line "$row.scsiCanonicalName = $vm.ScsiCanonicalName"  to avoid the double information. 

Mehdi.

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

$VMS = Get-VM -Name "MyVM"  | Get-HardDisk -DiskType "RawPhysical", "RawVirtual"

$report = @()

foreach ($vm in $VMS) {

   $row = "" | select Parent, DiskType, ScsiCanonicalName, Persistence, Filename,"LunID", CapacityGB

   $row.Parent = $vm.Parent

   $row.Disktype = $vm.disktype

   $row.scsiCanonicalName = $vm.ScsiCanonicalName

   $row.Persistence = $vm.Persistence

   $row.Filename = $vm.Filename

   $row."LunID" = ($vm.Parent.VMHost.ExtensionData.Config.StorageDevice.MultipathInfo.Lun |

      where{$_.Id -eq $vm.ExtensionData.Backing.LunUuid}).Path[0].Name.Split('L')[1]

   $row.CapacityGB = $vm.CapacityGB

   $report += $row

}

$report | export-csv -Path "Path" -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
MehdiF
Enthusiast
Enthusiast
Jump to solution

hello LucD,

It's Perfect. Thank you very much 😉 

I will delete this line "$row.scsiCanonicalName = $vm.ScsiCanonicalName"  to avoid the double information. 

Mehdi.

0 Kudos