Hi Everyone,
I need some help to get the report as .CSV and add the one column that is 'Resource Pool Name'.
how to add it into the below Script created by Mr. LucD:
$VmInfo = ForEach ($Datacenter in (Get-Datacenter))
{
ForEach ($VM in ($Datacenter | Get-VM | Sort-Object | Where-Object { $_.powerstate -match "on" } | Get-VMGuest))
{
$vm | Select-Object @{ N = "VM_NAME#"; E = { $vm.Hostname } },
@{ N = "VM_CPU_Core#"; E = { $VM.VM.NumCPU } },
@{ N = "VM_MemoryGB"; E = { $VM.VM.MemoryGB } },
@{ N = "VM_DiskGB"; E = { [math]::Round(($VM.VM.Extensiondata.Guest.Disk | Measure-Object -Property Capacity -Sum | Select-Object -ExpandProperty Sum)/1GB, 0) }},
@{ N = "VM_IP#"; E = { $vm.IPAddress } },
@{ N = "VM_OS"; E = { $vm.OSFullName } },
@{ N = "VM_DC"; E = { $Datacenter.name } },
@{ N = 'VM_Cluster'; E = { (Get-Cluster -VM $VM.VM).Name } },
@{ N = "VM_NOTES"; E = { $VM.VM.Notes } },
@{ N = 'VM_Annotations'; E = { (Get-Annotation -Entity $VM.VM).Value } }
}
}
$paramExportCsv = @{
Path = "d:\powershell_temp\report_vm_notes.csv"
NoTypeInformation = $true
UseCulture = $true
}
$VmInfo | Export-Csv @paramExportCsv
Thank you in advance.
You can add a calculated property like this
@{ N = "ResourcePool"; E = { $vm.VM.ResourcePool.Name} },
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can add a calculated property like this
@{ N = "ResourcePool"; E = { $vm.VM.ResourcePool.Name} },
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That's great, thank you LucD for the assistance in this matter.