VMware Cloud Community
EdZ
Contributor
Contributor
Jump to solution

Script to export LUN information - trying to iron out the kinks

I have a script that is designed to export details on the LUN information for the ESX hosts in a particular location. Here's the syntax:

Report_LUN_Details_Location.ps1 Where is fed into the -location parameter inside the script. The script outputs the contents to c:\temp in CSV format. Most of it works, but I'm having trouble with the path information which used to report properly. Also there are some errors during script execution but which don't affect the outcome. It also has some customized fields to report data from EMC Symmetrix devices. Any tips on how to improve/correct the script would be most appreciated.

Thanks,

Ed

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The string error you are seeing is because the UUID for local disks is shorter than the one for SAN disks.

Most of the time these local disks have the word "local" in the displayname.

So you could filter them out by replacing this

	foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware"})

by

	foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware" -and $_.DisplayName -notmatch "local"})

The empty DevicePath property is due to non-disk devices.

If I replaced this line

	foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware"})

by this line

	foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware" -and $_.LunType -eq "disk"})

that problem is gone.

Btw why do you test for vendor VMware ?

Is your set up running on a VMware Workstation perhaps ?

The complete script is attached.

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

The string error you are seeing is because the UUID for local disks is shorter than the one for SAN disks.

Most of the time these local disks have the word "local" in the displayname.

So you could filter them out by replacing this

	foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware"})

by

	foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware" -and $_.DisplayName -notmatch "local"})

The empty DevicePath property is due to non-disk devices.

If I replaced this line

	foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware"})

by this line

	foreach ($Device in $VMHostObj.Config.StorageDevice.SCSILUN | Where-Object {$_.Vendor -ne "VMware" -and $_.LunType -eq "disk"})

that problem is gone.

Btw why do you test for vendor VMware ?

Is your set up running on a VMware Workstation perhaps ?

The complete script is attached.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
EdZ
Contributor
Contributor
Jump to solution

Thanks Luc! The comparison for vendor name VMWare is in there to make sure that only external SAN devices are queried.

0 Kudos