1 2 Previous Next 29 Replies Latest reply on May 20, 2015 3:54 PM by justinsmith Go to original post
      • 15. Re: Command or script needed to get Datastore, NAA identifier and multipath
        LucD Guru
        vExpertUser ModeratorsCommunity Warriors

        The $clusName variable seems to be empty.

        That means the parameters were not passed correctly, or the param line in the script is not correct.

         

        Could you perhaps attach a screenshot of the PowerCLI prompt where you call the function ?

        Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
        • 16. Re: Command or script needed to get Datastore, NAA identifier and multipath
          jessem Enthusiast

          Ok, I checked it again and I fat fingered it!  It works, however....I don't see anywhere in the report/csv where it gives me the multipathing (fixed, round robin, etc.) policy?

          • 17. Re: Command or script needed to get Datastore, NAA identifier and multipath
            LucD Guru
            Community WarriorsUser ModeratorsvExpert

            No, the multipathing is not in that report. Although it isn't too hard to include it.

             

            But then take the other script with the change I suggested, that should give you the multipathing as well

            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
            • 18. Re: Command or script needed to get Datastore, NAA identifier and multipath
              jessem Enthusiast

              so replace the line:

               

               

              $_.Info.Vmfs.Extent | %{

               

               

               

               

              with this?

               

               

              $entry.datastorename= $datastore | Where-Object {($_.extensiondata.info.vmfs.extent | %{$_.diskname}) -contains $disk.canonicalname}|select -expand name

              • 19. Re: Command or script needed to get Datastore, NAA identifier and multipath
                LucD Guru
                vExpertCommunity WarriorsUser Moderators

                No, you replace this line

                $entry.datastorename= $datastore | Where-Object { $_.extensiondata.info.vmfs.extent.diskname -like $disk.canonicalname}|select -expand name

                with this line

                $entry.datastorename= $datastore | Where-Object {($_.extensiondata.info.vmfs.extent | %{$_.diskname}) -contains $disk.canonicalname}|select -expand name
                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 20. Re: Command or script needed to get Datastore, NAA identifier and multipath
                  jessem Enthusiast

                  I can't find that line in your script?  Where is this?

                  $entry.datastorename= $datastore | Where-Object { $_.extensiondata.info.vmfs.extent.diskname -like $disk.canonicalname}|select -expand name


                  Here is the script I have, unless I have the wrong one?

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

                  param($clusName,$csvName=("C:\Temp\" + $clusName + "-LUN.csv"))

                   

                   

                  $rndNum = Get-Random -Maximum 99999

                   

                   

                  $LunInfoDef = @"

                    public string ClusterName;

                    public string CanonicalName;

                    public string UsedBy;

                    public string SizeMB;

                  "@

                  $LunInfoDef = "public struct LunInfo" + $rndNum + "{`n" + $LunInfoDef

                   

                   

                  $esxServers = Get-Cluster $clusName | Get-VMHost | Sort-Object -Property Name

                  $esxServers | %{

                    $LunInfoDef += ("`n`tpublic string " + ($_.Name.Split(".")[0]) + ";")

                  }

                  $LunInfoDef += "`n}"

                   

                   

                  Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef

                   

                   

                  $scsiTab = @{}

                  $esxServers | %{

                    $esxImpl = $_

                   

                   

                  # Get SCSI LUNs

                    $esxImpl | Get-ScsiLun | where {$_.LunType -eq "Disk"} | %{

                   

                   

                    $key = $esxImpl.Name.Split(".")[0] + "-" + $_.CanonicalName.Split(".")[1]

                    if(!$scsiTab.ContainsKey($key)){

                   

                   

                    $scsiTab[$key] = $_.CanonicalName,"",$_.CapacityMB

                    }

                    }

                   

                   

                  # Get the VMFS datastores

                    $esxImpl | Get-Datastore | where {$_.Type -eq "VMFS"} | Get-View | %{

                    $dsName = $_.Name

                    $_.Info.Vmfs.Extent | %{

                    $key = $esxImpl.Name.Split(".")[0] + "-" + $_.DiskName.Split(".")[1]

                    $scsiTab[$key] = $scsiTab[$key][0], $dsName, $scsiTab[$key][2]

                    }

                    }

                  }

                   

                   

                  # Get the RDM disks

                  Get-Cluster $clusName | Get-VM | Get-View | %{

                    $vm = $_

                    $vm.Config.Hardware.Device | where {$_.gettype().Name -eq "VirtualDisk"} | %{

                    if("physicalMode","virtualmode" -contains $_.Backing.CompatibilityMode){

                    $disk = $_.Backing.LunUuid.Substring(10,32)

                    $key = (Get-View $vm.Runtime.Host).Name.Split(".")[0] + "-" + $disk

                    $scsiTab[$key][1] = $vm.Name + "/" + $_.DeviceInfo.Label

                    }

                    }

                  }

                   

                   

                  $scsiTab.GetEnumerator() | Group-Object -Property {$_.Key.Split("-")[1]} | %{

                    $lun = New-Object ("LunInfo" + $rndNum)

                    $lun.ClusterName = $clusName

                    $_.Group | %{

                    $esxName = $_.Key.Split("-")[0]

                    $lun.$esxName = "ok"

                    if(!$lun.CanonicalName){$lun.CanonicalName = $_.Value[0]}

                    if(!$lun.UsedBy){$lun.UsedBy = $_.Value[1]}

                    if(!$lun.SizeMB){$lun.SizeMB = $_.Value[2]}

                   

                   

                    }

                    $lun

                  } | Export-Csv $csvName -NoTypeInformation -UseCulture

                  Invoke-Item $csvName


                  • 21. Re: Command or script needed to get Datastore, NAA identifier and multipath
                    LucD Guru
                    vExpertUser ModeratorsCommunity Warriors

                    Not in my script, in the one that Conrad gave earlier

                    Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                    • 22. Re: Command or script needed to get Datastore, NAA identifier and multipath
                      jessem Enthusiast

                      great, that worked!  one last request, pardon my ignorance.  Any way to get the hostname added to the csv report?

                      • 23. Re: Command or script needed to get Datastore, NAA identifier and multipath
                        LucD Guru
                        vExpertCommunity WarriorsUser Moderators

                        Try something like this

                         

                        $datastore = get-datastore

                        $disks = get-cluster 'windows 01' | get-vmhost | get-scsilun -luntype disk
                        $entry = @()
                        $output = @()
                        ForEach ($disk in $disks){
                         
                        $entry = "" | Select DataStorename, HostName, Canonicalname, Multipathing
                         
                        $entry.datastorename= $datastore | Where-Object {($_.extensiondata.info.vmfs.extent | %{$_.diskname}) -contains $disk.canonicalname}|select -expand name
                         
                        $entry.HostName = $disk.VMHost.Name
                         
                        $entry.canonicalname=$disk.canonicalname
                         
                        $entry.multipathing=$disk.multipathpolicy
                         
                        $output += $entry
                        }
                        $output | Export-csv c:\lun_multipath.csv
                        Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                        • 24. Re: Command or script needed to get Datastore, NAA identifier and multipath
                          jessem Enthusiast

                          Thanks for you and Conrad's help!

                          • 25. Re: Command or script needed to get Datastore, NAA identifier and multipath
                            justinsmith Enthusiast

                            Im trying to post a reply on your site but it doesnt seem to be working so I'll send my response here...

                             

                            The script works great for me other than the fact that the csv that gets created doesnt have a value under VMName which would be cool to have. I also get an error referring to the CanonicalName, but that data does show in the csv file. I get the error numerous times and it looks like it per host, heres the error.

                             

                            Get-ScsiLun : Cannot validate argument on parameter 'CanonicalName'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

                            At H:\VM Scripts\storage_details.ps1:76 char:59

                            + $RuntimeName = Get-ScsiLun -vmhost $vmHost -CanonicalName $naaid | Select -Expan ...

                            +                                                           ~~~~~~

                                + CategoryInfo          : InvalidData: (:) [Get-ScsiLun], ParameterBindingValidationException

                                + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetScsiLun

                            • 26. Re: Command or script needed to get Datastore, NAA identifier and multipath
                              LucD Guru
                              vExpertCommunity WarriorsUser Moderators

                              Yeah, comments on my blog need to be approved before you see them, otherwise I would have too much spam comments.

                               

                              Could it be that you have some datastores that are not VMFS datastores but NFS or iSCSI ?

                              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                              • 27. Re: Command or script needed to get Datastore, NAA identifier and multipath
                                justinsmith Enthusiast

                                That would make sense actually....

                                 

                                What about getting the VMName to populate? Its just showing as blank fields

                                • 28. Re: Command or script needed to get Datastore, NAA identifier and multipath
                                  LucD Guru
                                  User ModeratorsvExpertCommunity Warriors

                                  Are you referring to my LUN report – datastore, RDM and node visibility post ?

                                  In there the VMname is shown in the UsedBy column if the LUN is used as RDM

                                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                  • 29. Re: Command or script needed to get Datastore, NAA identifier and multipath
                                    justinsmith Enthusiast

                                    Yes Im referring to that post.

                                     

                                    I put 2 and 2 together. We have so many blanks in either the VMName and or the Datastore name along with 1100+ rows, it made it kind of a pain to find what I needed. But Filter > sort in Excel is your friend.

                                     

                                    Thanks again

                                    1 2 Previous Next