1

I want to add values to a PropertyBag.

How is it possible to check if the value is already in the PropertyBag?

I know one can use an array, list, etc. But how can I use the $bag/$api object to do this check?

$api = New-Object -comObject “MOM.ScriptAPI”
$bag = $api.CreatePropertyBag()
$bag.AddValue("TestValue1","1234")

I'm searching for something like this:

if($bag -match "TestValue1")
{"In the Bag!"}

But, unfortunately, it's not working.

LaPhi
  • 5,675
  • 21
  • 56
  • 78

1 Answers1

0

I do not have SCOM on a server I can access, but could you do the following to get the bag contents and check against it?

$api = New-Object -comObject “MOM.ScriptAPI”
$bag = $api.CreatePropertyBag()
$bagContents = $api.Return($bag)
Norman Skinner
  • 6,729
  • 1
  • 19
  • 22