Hi LucD, The cript seems to be running for more than 6 hours. I will like to remove some lines from it and just have it get me information about VM hosts, VM's, WWN names of the hosts and the ...
See more...
Hi LucD, The cript seems to be running for more than 6 hours. I will like to remove some lines from it and just have it get me information about VM hosts, VM's, WWN names of the hosts and the LUN ID of whatever is presented from the storage array. What I'm trying to get is the LUN ID that I can tie to each VM through the host. We are trying to identify what VM and hosts are tied to specific LUN iD's. Below is the script; $VmInfo = ForEach ($Datacenter in (Get-Datacenter | Sort-Object -Property Name)) { ForEach ($Cluster in ($Datacenter | Get-Cluster | Sort-Object -Property Name)) { ForEach ($VM in ($Cluster | Get-VM | Sort-Object -Property Name)) { ForEach ($HardDisk in ($VM | Get-HardDisk | Sort-Object -Property Name)) { $ds = Get-Datastore -Name ($HardDisk.FileName.Split("]")[0].TrimStart("[")) | Select -First 1 $dsLun = @() $dsLunID = @() $dsWwwn = @() Get-ScsiLun -Datastore $ds | Sort-Object -Property CanonicalName -Unique | %{ $dsLun += $_.CanonicalName $dsLunID += $_.RunTimeName.Split(':')[-1].Trim('L') } $esx = Get-VMHost -Name $vm.VMHost.Name $lunKey = @() $lunKey = $esx.ExtensionData.Config.StorageDevice.ScsiLun | where {$dsLun -contains $_.CanonicalName} | %{$_.Key} $lunWWN = @() $lunWWN = $esx.ExtensionData.Config.StorageDevice.MultipathInfo.Lun | where {$lunKey -contains $_.Lun} | %{ $_.Path | %{"{0:x}" -f $_.Transport.NodeWorldWideName} } | Sort-Object -Unique "" | Select-Object -Property @{N="VM";E={$VM.Name}}, @{N="VM CPU#";E={$vm.ExtensionData.Config.Hardware.NumCPU/$vm.ExtensionData.Config.Hardware.NumCoresPerSocket}}, @{N="VM CPU Core#";E={$vm.NumCPU}}, @{N="Datacenter";E={$Datacenter.name}}, @{N="Cluster";E={$Cluster.Name}}, @{N="Host";E={$vm.VMHost.Name}}, @{N="Host CPU#";E={$vm.VMHost.ExtensionData.Summary.Hardware.NumCpuPkgs}}, @{N="Host CPU Core#";E={$vm.VMHost.ExtensionData.Summary.Hardware.NumCpuCores/$vm.VMHost.ExtensionData.Summary.Hardware.NumCpuPkgs}}, @{N="Hard Disk";E={$HardDisk.Name}}, @{N="Datastore";E={$ds.Name}}, @{N="LUN";E={[string]::Join(',',$dsLun)}}, @{N="LUNID";E={[string]::Join(',',$dsLunId)}}, @{N="LUNWWN";E={[string]::Join(',',$lunWWN)}}, @{N="VMConfigFile";E={$VM.ExtensionData.Config.Files.VmPathName}}, @{N="VMDKpath";E={$HardDisk.FileName}}, @{N="VMDK Size";E={($vm.extensiondata.layoutex.file|?{$_.name -contains $harddisk.filename.replace(".","-flat.")}).size/1GB}}, @{N="Drive Size";E={$HardDisk.CapacityGB}} } } } } $VmInfo | Export-Csv -NoTypeInformation -UseCulture -Path "c:\scripts\reports\report.csv"