The title may be poor, so I’ll try to explain.
I’ve writing a DSC Resource and I’d like to do something seemingly simple: a if($var1 -eq $var2) sort of thing. What I’m running into, however is what I"m assuming is a formatting problem between the two variables.
Quick example is I grab a on of those fun values that has child objects. Grabbing it is rather easy and the output looks like this:
$var1 = $coll.Rules $var1 QueryExpression : samplehere QueryID : 1 RuleName : x64 PCs
So when I grab $rules i get the above. So I tried to make a hashtable that mimics that dump … made that like this:
$var2 = @(
@{
QueryExpression = "samplehere"
QueryID = "1"
RuleName = "x64 PCs"
}
)
$var2
Name Value
RuleName x64 PCs
QueryExpression samplehere
QueryID 1
now if i do a simple if ($var1.RuleName -eq $var2.RuleName) everything works as expected. But if i try to match the entire value of (var1 -eq var2) I fail. I’m guessing the two expressions are not formatted exactly the same, but I have no idea (sorry for being so new) how to format my “hand crafted variable” to match the value I’m reading off the system.
Anyone have anyplace they can point me on how to handle this?
(context: trying to create a DSC resource to manage something where one of the variables can have 'x" rules defined in it. I want to be able to read the entirety of the variable and match against my DSC configuration, so I’m debating using a hashtable to store all variables then compare, but no matter what I can’t match the format so my test will always be $false)