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.
davesnbAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
$diff = $pageresponse.pscomputername | ? { $_ -notin $publicstarted.pscomputername }

Open in new window

0
footechCommented:
I'm going to assume that $pageresponse and $publicstarted are object arrays that each have a pscomputername property.
$diff = Compare-Object -ReferenceObject $pageresponse -DifferenceObject $publicstarted -Property pscomputername | Select -ExpandProperty PsComputerName

Open in new window

This will work whether there are extra items in either array.

However, if $pageresponse and $publicstarted aren't object arrays, then the approach would have to be changed.  For example, if $pageresponse is a single object, and its pscomputername property is a multiline string, or a string array.  To check, try providing the result of the following:
$pageresponse.GetType()
$pageresponse | gm

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
davesnbAuthor Commented:
Yes, thank you the first worked !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.