View Only
  • 1.  Resource Pool issue with PowerCLI

    Posted Dec 19, 2012 11:37 PM

    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 :

    Name                 Id
    ----                 --
    1_OVC01_GOLD         ResourcePool-resgroup-3603

    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                      : /

    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.


  • 2.  RE: Resource Pool issue with PowerCLI
    Best Answer

    Posted Dec 20, 2012 12:20 AM

    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

  • 3.  RE: Resource Pool issue with PowerCLI

    Posted Dec 20, 2012 03:05 AM

    Thanks for your example. You help me a lot.