I am trying to determine the best way to display the Memory and vCPU Hot Add/Plug settings in the PowerCLI console. I am currently using this code to display these settings but I am not sure if the output is correct or if I can adjust it any way to improve it:
Get-Datacenter | Get-VM | Get-View | Select $($row.Name),
@{N="CpuHotAddEnabled";E={$_.Config.CpuHotAddEnabled}},@{N="MemoryHotAddEnabled";E={$_.Config.MemoryHotAddEnabled}} |
write-host -foregroundcolor green
Write-Host ""
The output from this code is:
@{VM1=; CpuHotAddEnabled=True; MemoryHotAddEnabled=True}
@{VM1=; CpuHotAddEnabled=True; MemoryHotAddEnabled=True}
@{VM1=; CpuHotAddEnabled=False; MemoryHotAddEnabled=False}
@{VM1=; CpuHotAddEnabled=False; MemoryHotAddEnabled=False}
I have verified that both Memory and vCPU Hot Add/Plug settings are enabled and the output is somewhat confusing me - it correctly indicates that both are enabled but then proceeds to show that their enabled status is 'False' in the proceeding lines. I am wondering if there is any adjustment possible to improve this to only show the true status of these settings.
Thank you for any help you may provide,
What does this say?
Get-Datacenter | Get-VM |
Select Name,
@{N="CpuHotAddEnabled";E={$_.ExtensionData.Config.CpuHotAddEnabled}},
@{N="MemoryHotAddEnabled";E={$_.ExtensionData.Config.MemoryHotAddEnabled}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If I leave it as just 'Name' it shows all the VMs in a single line:
Name CpuHotAddEnabled MemoryHotAddEnabled
---- ---------------- -------------------
VM1 True True
VM2 True True
VM3 False False
VM4 False False
If I change the 'Name' to the VM I want to look at specifically I get:
VM1 CpuHotAddEnabled MemoryHotAddEnabled
----------- ---------------- -------------------
True True
True True
False False
False False
How did you change the name?
Can you share the code?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I just took your code and replaced it like:
Get-Datacenter | Get-VM |
Select VM1,
@{N="CpuHotAddEnabled";E={$_.ExtensionData.Config.CpuHotAddEnabled}},
@{N="MemoryHotAddEnabled";E={$_.ExtensionData.Config.MemoryHotAddEnabled}}
It doesn't seem to be working now that I am trying it again though
EDIT: Nevermind, I was missing the comma after the VM1 name. It is working as I pasted previously
Try like this
Get-VM -Name VM1 |
Select Name,
@{N="CpuHotAddEnabled";E={$_.ExtensionData.Config.CpuHotAddEnabled}},
@{N="MemoryHotAddEnabled";E={$_.ExtensionData.Config.MemoryHotAddEnabled}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked perfectly that time - Thank you for your help!
Just pipe the results to Export-Csv
Select Name,
@{N="CpuHotAddEnabled";E={$_.ExtensionData.Config.CpuHotAddEnabled}},
@{N="MemoryHotAddEnabled";E={$_.ExtensionData.Config.MemoryHotAddEnabled}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
By the looks of it you are using a rather old PowerCLI version.
And that error is with the Get-VM cmdlet, nothing related to the Export-CSV.
It seems that Get-VM already gives an error.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference