Avatar of davesnb
davesnb
Flag 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.
Powershell

Avatar of undefined
Last Comment
davesnb

8/22/2022 - Mon
Qlemo

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

Open in new window

ASKER CERTIFIED SOLUTION
footech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
davesnb

ASKER
Yes, thank you the first worked !
Your help has saved me hundreds of hours of internet surfing.
fblack61