We help IT Professionals succeed at work.

Comparing two variable properties

davesnb
davesnb asked
on
96 Views
Last Modified: 2017-03-09
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.
Comment
Watch Question

Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015

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

Open in new window

CERTIFIED EXPERT
Top Expert 2014
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Yes, thank you the first worked !

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions