Bipul Kumar
Bipul Kumar

Reputation: 39

compare-object doesn't give any output

i run

$serv1=gwmi -Namespace Root\cimv2 -Class Win32_service

i stop some services manually and then run

$serv2=gwmi -Namespace Root\cimv2 -Class Win32_service

and then i compare these 2 objects

compare-object $serv1 $serv2

compare-object -referenceobject $serv1 -differenceobject $serv2

both doesn't return any difference however both have some values different

Upvotes: 0

Views: 144

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174920

Compare-Object compares the Path property of each wmi instance object in the input collections - they will be the same no matter whether the service is running or not.

Use the -Property parameter to compare on specific properties, ie.

Compare-Object $serv1 $serv2 -Property Name,State

Upvotes: 1

Related Questions