0

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

Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
Bipul Kumar
  • 39
  • 1
  • 7

1 Answers1

1

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
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206