SCOMPowerShellPropertyBagTypes.ps1


  # Here we create the com object
  $api = new-object -comObject 'MOM.ScriptAPI'
  # From the com object we spawn the bag. Now we can stuff things into the bag.
  $bag = $api.CreatePropertyBag()

  # Here I've added an assortment of different type things to the bag.
  # They each have a name and a value.
  $bag.AddValue('[String]"My String"', [String]"My String" )
  $bag.AddValue('[Decimal]9876543210987654321', [Decimal]9876543210987654321 )
  $bag.AddValue('[Decimal]9.8', [Decimal]9.8 )
  $bag.AddValue('[Double]987654321.88',[Double]987654321.88 )
  $bag.AddValue('[Double]987654321', [Double]987654321 )
  $bag.AddValue('[Double]9876543210987654321', [Double]9876543210987654321 )
  $bag.AddValue('[Int]4', [Int]4 )
  $bag.AddValue('[Int]4.8', [Int]4.8 )
  $bag.AddValue('[Float]55.66', [Float]55.66 )
  $bag.AddValue('[Float]9876543210987654321.66', [Float]9876543210987654321.66 )
  $bag.AddValue('[Float]55', [Float]55 )
  $bag.AddValue('[byte]9876543210987654321', [byte]98 )
  $bag.AddValue('[Long]987654321', [Long]987654321 )
  $bag.AddValue('[Long]987654321.00', [Long]987654321.00 )
  $bag.AddValue('[Long]9876543219876543210987654321',[Long]987654321987654321 )
  $bag.AddValue('[Single]9876543219876543210987654321', [Single]9876543219876543210987654321 )
  $bag.AddValue('[Single]9876.987', [Single]9876.987 )
  $bag.AddValue('[Char]"a"', [Char]"a" )
  $bag.AddValue('[Bool]$true', [Bool]$true )
  $bag.AddValue('[Bool]$false', [Bool]$false )
  $bag.AddValue('[Datetime]"03/04/2012"', [Datetime]"03/04/2012" )
  $bag.AddValue('$Null', $Null )

  # Here is how I would ordinarily return the bag so
  # that the SCOM workflow can use the contents of the bag.
  #$bag

  # Here is how I can display the contents of the bag to the screen. This is
  # useful only when testing the script manually.
  $api.Return($bag)