Hi Everyone
I'm trying to understand why I have these differences below:
1) When I ran this command from PowerCLI console "Get-ResourcePool 1_OVC01_GOLD". The result is :
2) When I ran the same command from a PS1 PowerShell Script, the result is different :
ParentId : ResourcePool-resgroup-411
Parent : Resources
CpuSharesLevel : Custom
NumCpuShares : 2000
CpuReservationMHz : 0
CpuExpandableReservation : True
CpuLimitMHz : -1
MemSharesLevel : Custom
NumMemShares : 2000
MemReservationMB : 1045
MemExpandableReservation : True
MemLimitMB : -1
Name : 1_OVC01_GOLD
CustomFields : {}
ExtensionData : VMware.Vim.ResourcePool
Id : ResourcePool-resgroup-3603
Uid : /VIServer=serv_vcadmin@am.lafargeone.net@amavcs01.am.lafargeone.net:443/ResourcePool=ResourcePool-resgroup-3603/
3) I would like to extract the values of NumCpuShares and NumMemShares on some output but the following comment doesn't work. Can someone explain me why ?
Get-ResourcePool 1_OVC01_GOLD | Select-String -pattern "NumCpuShares"
Get-ResourcePool 1_OVC01_GOLD | Select-String -pattern "NumMemShares"
Thanks for your help.
JEFF
The object that is returned is the same in both cases, which you can check by running from the prompt or in your script.
Get-ResourcePool 1_OVC01_GOLD | Select *
The difference is there because of the way the output handler in PowerShell shows you the object. For that the handler uses the .ps1xml files. These define which properties of an object are displayed and in which format.
To extract the values for those specific properties you can do
Get-ResourcePool 1_OVC01_GOLD | Select -ExpandProperty NumCpuShares
Get-ResourcePool 1_OVC01_GOLD | Select -ExpandProperty NumMemShares
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The object that is returned is the same in both cases, which you can check by running from the prompt or in your script.
Get-ResourcePool 1_OVC01_GOLD | Select *
The difference is there because of the way the output handler in PowerShell shows you the object. For that the handler uses the .ps1xml files. These define which properties of an object are displayed and in which format.
To extract the values for those specific properties you can do
Get-ResourcePool 1_OVC01_GOLD | Select -ExpandProperty NumCpuShares
Get-ResourcePool 1_OVC01_GOLD | Select -ExpandProperty NumMemShares
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for your example. You help me a lot.