Skip to content

Instantly share code, notes, and snippets.

@midnightfreddie
Last active October 18, 2017 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save midnightfreddie/d317d151dc28d8244eea8ebb9b70c8ba to your computer and use it in GitHub Desktop.
Save midnightfreddie/d317d151dc28d8244eea8ebb9b70c8ba to your computer and use it in GitHub Desktop.
$Services = @(
"netlogon"
"spooler"
)
$Computers = @(
"."
"iis"
)
Get-Service -Name $Services -ComputerName $Computers -ErrorAction SilentlyContinue |
Where-Object { $PSItem.Status -eq "Running" } |
Group-Object -Property MachineName |
Where-Object { $PSItem.Count -ge $Services.Count } |
Select-Object -ExpandProperty Name |
ForEach-Object {
Write-Output ("$PSItem is running " + ($Services -join " and ") )
}
$Services = @(
"netlogon"
"spooler"
)
$Computers = @(
"."
"iis"
)
$Computers | ForEach-Object {
if ((
Get-Service -Name $Services -ComputerName $PSItem -ErrorAction SilentlyContinue |
Where-Object { $PSItem.Status -eq "Running" }
).Count -ge $Services.Count) {
Write-Output ("$PSItem is running " + ($Services -join " and ") )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment