obireb's Posts

It errored out. Below is the original one without the "Used Space Comment" Maybe there was a typo when you made the changes. $report = foreach($esx in Get-VMHost){     foreach($hbaKey in ($es... See more...
It errored out. Below is the original one without the "Used Space Comment" Maybe there was a typo when you made the changes. $report = foreach($esx in Get-VMHost){     foreach($hbaKey in ($esx.Extensiondata.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -like "*FibreChannelHba*"})){ if($hbaKey.Target){ foreach($tgtKey in $hbaKey.Target){                 foreach($lunKey in $tgtKey.Lun){ $hba = $esx.Extensiondata.Config.StorageDevice.HostBusAdapter | where {$_.Key -eq $hbaKey.Adapter} $lun = $esx.Extensiondata.Config.StorageDevice.ScsiLun | where {$_.Key -eq $lunKey.ScsiLun} $datastore = $esx | Get-Datastore | Where-Object {(%{$_.ExtensionData.Info.Vmfs.Extent} | %{$_.DiskName}) -match $lun.CanonicalName} Select-Object -InputObject $lun -Property @{N="Cluster";E={Get-Cluster -VMHost $esx | %{$_.Name}}},@{N="Host";E={$esx.Name}},@{N="Datastore";E={$datastore | %{$_.Name}}},@{N="FreeSpace";E={$datastore | %{$_.FreeSpaceGB}}},@{N="Capacity";@{N="Used Space (GB)";E={$datastore | %{$_.CapacityGB}}},@{N="Virtual Machines";E={[string]::Join(",", (Get-VM -Datastore $datastore))}}, @{N="HBA";E={$hba.Device}}, CanonicalName,DisplayName,@{N="LUN";E={$lunKey.Lun}}                 }             }         }     } } $report | Export-Csv "C:\temp\CF03-report.csv" -NoTypeInformation -UseCulture
Hi Skan070, Can we add used space to the script? I left that out. Thanks,
Thanks Skan070.
I'm trying to add a line to this script and the line should also show VM's, cluster and how much free and used space on the LUN's. Also I will like the script to give me the name of the datastore... See more...
I'm trying to add a line to this script and the line should also show VM's, cluster and how much free and used space on the LUN's. Also I will like the script to give me the name of the datastores. $report = foreach($esx in Get-VMHost){     foreach($hbaKey in ($esx.Extensiondata.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -like "*FibreChannelHba*"})){ if($hbaKey.Target){ foreach($tgtKey in $hbaKey.Target){                 foreach($lunKey in $tgtKey.Lun){ $hba = $esx.Extensiondata.Config.StorageDevice.HostBusAdapter | where {$_.Key -eq $hbaKey.Adapter} $lun = $esx.Extensiondata.Config.StorageDevice.ScsiLun | where {$_.Key -eq $lunKey.ScsiLun} Select-Object -InputObject $lun -Property @{N="Host";E={$esx.Name}}, @{N="HBA";E={$hba.Device}}, CanonicalName,DisplayName,@{N="LUN";E={$lunKey.Lun}}                 }             }         }     } } $report | Export-Csv "C:\temp\lun-report.csv" -NoTypeInformation -UseCulture
LucD, Any updates?
Hi LucD, Below is the updated script which I modified. I just want it to give me the LUN ID's of the storage array mapped to each ESX and what VM's are associated with it. Let me know if it's ... See more...
Hi LucD, Below is the updated script which I modified. I just want it to give me the LUN ID's of the storage array mapped to each ESX and what VM's are associated with it. Let me know if it's correct. Thanks, $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="Datacenter";E={$Datacenter.name}},         @{N="Cluster";E={$Cluster.Name}},         @{N="Host";E={$vm.VMHost.Name}},         @{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:\temp\WWNCF03-LUNIDreport.csv"
LucD, Any update on this? Thanks,
My Bad LucD. Too many things on my mind. Yes I will like to see the LUN that is behind the virtualdisks that are connected to the VM and for the other question, most VM's reside on datastor... See more...
My Bad LucD. Too many things on my mind. Yes I will like to see the LUN that is behind the virtualdisks that are connected to the VM and for the other question, most VM's reside on datastores and the RDM's are exchange and DB servers.
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"
Just took a lot at the error and spotted that. My bad. Just restarted it again. I think it will take a couple of hours as I started one on another sever about 4 hours ago.
Hi LucD, I ran the script and it errored out on me. Attached is the error.
Thanks LucD. The script worked.
LuCD, any update on this?
They want a complete report and I tried to let them know but they insisted. Like I mentioned before, I will like both scenarios and will separate when needed. Thanks
Forgot to add that yes I will want the LUN info on each harddisk line.
Thanks for you response. I will like to have both meaning LUN ID on the main list and also separate so that I can compare or use the separate one for other analysis.
Hi LucD. The script about was what you originally helped me with. I will like to add a line to show the LUN ID's for each storage LUN on each hosts and also add a line for WWN names of the hosts ... See more...
Hi LucD. The script about was what you originally helped me with. I will like to add a line to show the LUN ID's for each storage LUN on each hosts and also add a line for WWN names of the hosts as well. Below is the script. Thanks. $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)) {         "" | 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={$HardDisk.FileName.Split("]")[0].TrimStart("[")}},         @{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"
Below is a script that does exactly what I want but I need to make some changes to it and need help adding the needed lines. I will like to add a line to show the LUN ID's for each storage LUN on... See more...
Below is a script that does exactly what I want but I need to make some changes to it and need help adding the needed lines. I will like to add a line to show the LUN ID's for each storage LUN on each hosts and also add a line for WWN names of the hosts as well. Below is the script. Thanks. $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)) {         "" | 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={$HardDisk.FileName.Split("]")[0].TrimStart("[")}},         @{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" Re: Get Complete Inventory PowerCLI
Hi LucD. The script about was what you originally helped me with. I will like to add a line to show the LUN ID's for each storage LUN on each hosts and also add a line for WWN names of the hosts ... See more...
Hi LucD. The script about was what you originally helped me with. I will like to add a line to show the LUN ID's for each storage LUN on each hosts and also add a line for WWN names of the hosts as well. Below is the script. Thanks. $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)) {         "" | 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={$HardDisk.FileName.Split("]")[0].TrimStart("[")}},         @{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" Re: Get Complete Inventory PowerCLI
Thanks a lot. It ran just fine.