This function “Compare-Services” will allow you to compare the running services of two computers. The first one is called the Reference Computer, the second is the Difference Computer. The output defaults to Compare-Object output. If you need an object to do further work with, this is what you want. If you don’t want to puzzle out what the “=>” and “<=” indicators mean, and you want a simple report, you can use the -FriendlyText switch will give you English text output, which will make more sense to many humans, at least the English speaking humans reading this blog. Windows remoting needs to be enabled on the computers being checked for this to work.
Example output:
Compare-Object style (PS object) output: InputObject SideIndicator ----------- ------------- Distributed Link Tracking Client => Active Directory Web Services <= Application Information <= DFS Namespace <= DFS Replication <= DHCP Server <= DNS Server <= Intersite Messaging <= Kerberos Key Distribution Center <= Active Directory Domain Services <= Smart Card Device Enumeration Service <= Shell Hardware Detection <= Virtual Disk <= Friendly Text (English) output: "Distributed Link Tracking Client" is on lab01 (not on dc1) "Active Directory Web Services" is on dc1 (not on lab01) "Application Information" is on dc1 (not on lab01) "DFS Namespace" is on dc1 (not on lab01) "DFS Replication" is on dc1 (not on lab01) "DHCP Server" is on dc1 (not on lab01) "DNS Server" is on dc1 (not on lab01) "Intersite Messaging" is on dc1 (not on lab01) "Kerberos Key Distribution Center" is on dc1 (not on lab01) "Active Directory Domain Services" is on dc1 (not on lab01) "Smart Card Device Enumeration Service" is on dc1 (not on lab01) "Shell Hardware Detection" is on dc1 (not on lab01) "Virtual Disk" is on dc1 (not on lab01)
And here is the function:
function Compare-Services ($ReferenceComputer, $DifferenceComputer, [switch]$FriendlyText) { $ReferenceServices = (Get-Service -ComputerName $ReferenceComputer | where Status -EQ "Running").DisplayName $DifferenceServices = (Get-Service -ComputerName $DifferenceComputer | where Status -EQ "Running").DisplayName $CompareResult = Compare-Object -ReferenceObject $ReferenceServices -DifferenceObject $DifferenceServices if ($FriendlyText) { $CompareResult | foreach { if ($_.SideIndicator -eq "=>") {"`"$($_.InputObject)`" is on $DifferenceComputer (not on $ReferenceComputer)"} if ($_.SideIndicator -eq "<=") {"`"$($_.InputObject)`" is on $ReferenceComputer (not on $DifferenceComputer)"} } } else {$CompareResult} }
Aloha! :)
You wouldn’t believe how crazy the search results were just trying to find how to do this.
However, I’m not quite sure exactly what you mean by ‘On’ one computer or another?
What I’m looking for is a way to compare services between computers on same LAN as follows:
1. Which services are present on each one.
2. Status of services of each one (started, stopped)
3. Config of each one (disabled, manual, auto, auto-delayed etc.)
But if this lets you know which services are present & RUNNING,
it would be enough of a blessing at this point.
Manually comparing services can be a real pain.
Wondering also if Precious Nir Sofer or Syinternals has something for this?
Either way, your efforts are much appreciated.
Mahalo (thank you very much) for your help!
Ed, This script, as above will only consider Running (and therefor present) services on each computer. It could be modified to compare the config as will.
This should get you what you want.
Line 1 and 2 sets variables with the names of the computers.
Lines 4 and 5 gets the details of the services of each, selecting properties DisplayName, Status, StartType. Display name is the nice “English” name of the service. Status is Running, Stopped, etc. StartType is Manual, Automatic, Disabled, etc. The resulting object with the selected properties from the services are assigned to variables.
The last line compares the results. In PowerShell, look at the help for Compare-Object, but in a nutshell, SideIndicator “<=” refers to the Reference Computer, “=>” and refers to the Difference Computer.
Does this help?