Getting WWN from VMGuest names using PowerCLI script

Can anyone help me with pulling WWN based on VMguest?
I can do it based on VMHost but this is not exactly what is being asked of me.

I have a list of several hundred VM guests and was asked for their DataStore info and WWN info, I was able to get the DataStore info, but am not sure how to get the WWN per VMguest name.

Any help?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does all those VMs have Raw Disk Mapping (rdm)?
alexr54Author Commented:
Yes I believe they all are.
alexr54Author Commented:
I was using this script to pull the WWN and other info from the VMhost. However I was not able to tie this to a list of VMguests.

   $report = Get-Datacenter | % {    


      foreach($esx in Get-VMhost -Location $datacenter){  

        $esxcli = Get-EsxCli -VMHost $esx  

        $nic = Get-VMHostNetworkAdapter -VMHost $esx | Select -First 1 | select -ExpandProperty Name  

        $hba =Get-VMHostHBA -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"} |  Select -First 1 |select -ExpandProperty Name  

        Get-VMHostHBA -VMHost $esx -Type FibreChannel | where {$_.Status -eq "online"} |  

        Select @{N="Datacenter";E={$datacenter.Name}},  


                @{N="HostName";E={$($_.VMHost | Get-VMHostNetwork).HostName}},  




                @{Name="SerialNumber";Expression={$esx.ExtensionData.Hardware.SystemInfo.OtherIdentifyingInfo |Where-Object {$_.IdentifierType.Key -eq "Servicetag"} |Select-Object -ExpandProperty IdentifierValue}},  


                    if($esx.ExtensionData.Parent.Type -ne "ClusterComputeResource"){"Stand alone host"}  


                        Get-view -Id $esx.ExtensionData.Parent | Select -ExpandProperty Name  



                @{N="WWPN";E={((("{0:X}"-f $_.NodeWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},  

                @{N="WWN";E={((("{0:X}"-f $_.PortWorldWideName).ToLower()) -replace "(\w{2})",'$1:').TrimEnd(':')}},  

              # @{N="Fnicvendor";E={$ | ? {$_.Name -match ".*$($hba.hbadriver).*"} | Select -First 1 -Expand Vendor}},  

                @{N="Fnicvendor";E={$esxcli.hardware.pci.list() | where {$hba -contains $_.VMKernelName} |Select -ExpandProperty VendorName }},  



               # @{N="Enicvendor";E={$ | ? {$_.Name -match ".net.*"} | Select -First 1 -Expand Vendor}}  

                 @{N="Enicvendor";E={$esxcli.hardware.pci.list() | where {$nic -contains $_.VMKernelName} |Select -ExpandProperty VendorName }}  

                 #@{N="Enicvendor";E={$ | where {$ -eq $_.vmnic1} | select -First 1 -ExpandProperty Description }}  



$report | Export-Csv WWNreport.csv -NoTypeInformation -UseCulture

Open in new window

Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

It is very unlikely to have RDM on "several hundred" virtual machines as RDM is a special configuration that allow vm to attach to the raw storage.

Only vm with RDM would have WWN needed -
alexr54Author Commented:
I suppose I fall in that rare category.
For the VMguests with RDM, anyway to get the WWN?
alexr54Author Commented:
I guess what I am hoping for is a way to gather the VMFS info per VMGuest, which includes any and all possible datastore information.
LUN, DatastoreName, Capacity, guestname are most important.
Yes I believe they all are.
Do you have access to login and check? Again, having several hundred vms with RDM is unlikely. I am very interested to know, and perhaps you can prove me I am wrong.

I am not aware there is a powercli to query WWN on guest. But you can use get-harddisk cmdlet to determine if is a RDM disk, then it has WWN.
alexr54Author Commented:
I am in a very large company. So like I said I probably fall in that very rare category.
I did some more research and I cant find a way to pull the information I need without some sort of storage plugin.
It has nothing to do with the size the company.

RDM disks has it limitation therefore it normally be "all" of your  
vms. You can query the WWNs within the guest (windows or Linux) , you don't need s storage plugin to accomplish it.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Can you post one of screen shot  in vsphere that is running rdm?
alexr54Author Commented:
Yes on Monday when I get to the office I'll take a screen shot
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.