Automation

 View Only
  • 1.  Script to export LUN information - trying to iron out the kinks

    Posted Jul 14, 2010 04:00 PM

    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



  • 2.  RE: Script to export LUN information - trying to iron out the kinks
    Best Answer

    Posted Jul 14, 2010 04:52 PM

    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



  • 3.  RE: Script to export LUN information - trying to iron out the kinks

    Posted Jul 14, 2010 10:44 PM

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