{"id":1324,"date":"2013-12-09T10:30:00","date_gmt":"2013-12-09T15:30:00","guid":{"rendered":"http:\/\/enterpriseadmins.org\/blog\/?p=1324"},"modified":"2013-12-08T07:41:05","modified_gmt":"2013-12-08T12:41:05","slug":"powercli-getting-lun-paths-when-using-emc-powerpathve","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/scripting\/powercli-getting-lun-paths-when-using-emc-powerpathve\/","title":{"rendered":"PowerCLI: Getting LUN paths when using EMC PowerPath\/VE"},"content":{"rendered":"<p>A few weeks back I wanted to verify some path counts per LUN.  This is typically pretty easy and something that can be written as a one liner using standard PowerCLI cmdlets as such:<\/p>\n<pre>\r\nGet-VMHost | Get-ScsiLun | Get-ScsiLunPath\r\n<\/pre>\n<p>However, the above command wouldn&#8217;t return results in the customer environment.  After doing some testing, I realized that the issue was likely related to the presence of EMC PowerPath\/VE for multipathing on the hosts.  When using the GUI to view storage\/LUN properties other details like Path Selection Plugin (PSP) is also missing&#8230; but the path information I wanted was still available.  It took a little bit of poking around in the Get-View output, but I was able to come up with something to get me the data I was looking for.  Its not real pretty, but it is fast and helped me answer a couple questions.  I figured I would share the code here here in case anyone else runs into this issue.  If you have any comments\/suggestions on how to make this code better\/more complete please post them in the comments section.  <\/p>\n<pre><code class=\"language-1\">\r\n$dsHt = Get-View -ViewType Datastore -Property \"Info\",\"Summary.Type\" -Filter @{\"Summary.Type\"=\"VMFS\"} | \r\nSelect @{N=\"DSName\";E={$_.Info.Vmfs.Name}}, @{N=\"Capacity\";E={[math]::round( ($_.Info.Vmfs.Capacity \/ 1024 \/ 1024), 0)}}, \r\n@{N=\"Extent\";E={$_.Info.Vmfs.Extent[0].DiskName}}, @{N=\"VMFS Version\";E={$_.Info.Vmfs.Version}} | \r\nGroup-Object \"Extent\" -AsHashTable -AsString\r\n\r\n$results = @()\r\nGet-View -ViewType HostSystem -SearchRoot (Get-Cluster ClusterPod8).id -Property Name, Config.StorageDevice | %{\r\n  $thisHostName = $_.Name\r\n  $_.Config.StorageDevice.PlugStoreTopology.path | ?{$_.Name -match 'naa'} | Group-Object LunNumber | Sort-object Name | %{\r\n    try {\r\n      $thisNaaId = ($_.Group[0].Name -split \"naa.\")[1]\r\n      $results += New-Object psobject -Property @{\r\n        HostName = $thisHostName\r\n        LunNumber = $_.Name\r\n        PathCount = $_.Count\r\n        DSName = $dsHt[\"naa.$thisNaaId\"][0].DSName\r\n        Capacity = $dsHt[\"naa.$thisNaaId\"][0].Capacity\r\n        \"VMFS Version\" = $dsHt[\"naa.$thisNaaId\"][0].\"VMFS Version\"\r\n      }\r\n    } catch {\r\n      Write-Warning \"Found something with $thisNaaId\"\r\n    }\r\n  } # end this Lun\r\n} # end this host\r\n\r\n$results |Group-Object pathcount\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A few weeks back I wanted to verify some path counts per LUN. This is typically pretty easy and something that can be written as a one liner using standard PowerCLI cmdlets as such: Get-VMHost | Get-ScsiLun | Get-ScsiLunPath However, &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/scripting\/powercli-getting-lun-paths-when-using-emc-powerpathve\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-1324","post","type-post","status-publish","format-standard","hentry","category-scripting","category-virtualization"],"_links":{"self":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/comments?post=1324"}],"version-history":[{"count":1,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1324\/revisions"}],"predecessor-version":[{"id":1325,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1324\/revisions\/1325"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=1324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=1324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=1324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}