Link to home
Start Free TrialLog in
Avatar of davesnb
davesnbFlag for Canada

asked on

Comparing two variable properties

I have 2 variables with the same property values ( computername) . I wish to find the value that does not match . So below , I have my list of computers in var pageresponse in a invoke-webrequest stored variable .

$pageresponse.pscomputername

iasc9-web04
iasc9-web05
iasc9-web06
iasc9-web07
iasc9-web15
iasc9-web16
iasc9-web25
iasc9-web26
iasc9-web27
iasc9-web28
iasc9-web29
iasc9-web30
iasc9-web31
iasc9-web32
iasc9-web33

Open in new window


And , i also have a list of "started" computers in a stored variable of var publicstarted of property $publicstarted.pscomputername

$publicstarted.pscomputername
iasc9-web04
iasc9-web05
iasc9-web06
iasc9-web07
iasc9-web15
iasc9-web16
iasc9-web25
iasc9-web26
iasc9-web27
iasc9-web28
iasc9-web29
iasc9-web30
iasc9-web31
iasc9-web32
iasc9-web33
iasc9-web34

Open in new window


So I just wish to compare the 2 and return the value that is not matching , so in this example, iasc9-web34 should be returned and stored in a new var.

Your help is appreciated.
Avatar of Qlemo
Qlemo
Flag of Germany image

$diff = $pageresponse.pscomputername | ? { $_ -notin $publicstarted.pscomputername }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davesnb

ASKER

Yes, thank you the first worked !