scom discovery with powersehll variable as propertykey
Hello!
I have a script and stored the properties for discovery in an array.
also the values i was created are stored in an array.
now i want to set all the properties like
i = 0
foreach ( $propertyKey in $arrProperties ) {
$propertyValue = $arrValues[$i]
$classProperty = '$MP' + "Element[Name='MyClass']/" + $propertyKey + '$'
$instance.AddProperty("$classProperty", $propertyValue)
$i += 1
}
But at compilation in VS i get following error:
Incorrect expression specified: $MPElement[Name='MyClass']/. Unable to resolve this expression. Check the expression for errors. (Hints: Check for correct character casing (upper case/lower case), mismatched "$" signs, double quotes("), square brackets "[" or "]"). Here is a sample expression: $MPElement[Name="Windows!Microsoft.Windows.Computer"]/NetworkName$
is it possible to do this?
rg
Hansi