- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found how to retrieve the value of an ExtraConfig Key from this earlier thread (link below), but when I try to use it in an existing script, I have to further nest it, and the context is not correct. It does not error out, it just does not return a value.
How to use Get-View instead of Get-VM for Advanced Settings of a VM
Here is the snippet of code from my script, with the code that is returning NULL highlighted in bold purple.
Get-VM | get-view | Select @{N="VMName";E={$_.name}}, @{N="OSHostName";E={$_.guest.HostName}}, @{N="OS";E={$_.Summary.Config.GuestFullName}}, @{N="State";E={$_.Summary.Runtime.PowerState}}, @{N="ESXiHostName";E={(get-vmhost -Id $_.Runtime.Host.ToString()).name}},
@{N="vCenter";E={$global:DefaultVIServer.Name}}, @{N="vCPU";E={$_.Summary.Config.NumCpu}}, @{N="CorePerSocket";E={($_.Config.ExtraConfig | where {$_.Key -like 'cpuid.coresPerSocket'}).Value}}, @{N="Memory";E={$_.Summary.Config.MemorySizeMB}} , @{N="Storage";E={$_.Guest.Disk.Capacity}}, @{N="VMwareTools";E={$_.Guest.ToolsVersionStatus}},
@{N="CpuReservation";E={$_.Summary.Config.CpuReservation}}, @{N="MemoryReservation";E={$_.Summary.Config.MemoryReservation}}
LucD - since you provided the solution on the previous thread, I am hoping this might be an easy one for you.
Thanks,
David Griswold
PayPal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Under the ExtraConfig you will only find settings that are not present anywhere else in the VirtualMachine object.
In the case of CorePerSocket, there is a property under the VirtualHardware object, named NumCoresPerSocket that has the value you are looking for.
Consider ExtraConfig as a place to define virtual hardware settings that do not (yet) have a dedicated property.
Select @{N="VMName";E={$_.name}},
@{N="OSHostName";E={$_.guest.HostName}},
@{N="OS";E={$_.Summary.Config.GuestFullName}},
@{N="State";E={$_.Summary.Runtime.PowerState}},
@{N="ESXiHostName";E={(Get-VMHost -Id $_.Runtime.Host.ToString()).name}},
@{N="vCenter";E={$global:DefaultVIServer.Name}},
@{N="vCPU";E={$_.Summary.Config.NumCpu}},
@{N="CorePerSocket";E={$_.Config.Hardware.NumCoresPerSocket}},
@{N="Memory";E={$_.Summary.Config.MemorySizeMB}} ,
@{N="Storage";E={$_.Guest.Disk.Capacity}},
@{N="VMwareTools";E={$_.Guest.ToolsVersionStatus}},
@{N="CpuReservation";E={$_.Summary.Config.CpuReservation}},
@{N="MemoryReservation";E={$_.Summary.Config.MemoryReservation}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am sure there is a resource for everything in the VM View, but I have yet to find a definitive one. If you know of one, I would appreciate a link.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The only one that documents all the public properties and methods behind Get-View or ExtensionData, is the vSphere Web Services API 6.7 reference
But note that this is for the SOAP API.
For the REST API, you can use the API Explorer at VMware{code}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference