29 lines
829 B
PowerShell
29 lines
829 B
PowerShell
|
function Test-NagService {
|
|||
|
<#
|
|||
|
.SYNOPSIS
|
|||
|
Tests an array of machines looking for a single instance of the Alkami Nag Service
|
|||
|
.PARAMETER machineNames
|
|||
|
An array of machines to test against. These machines should be a single pod grouping.
|
|||
|
#>
|
|||
|
param(
|
|||
|
[array]$MachineNames
|
|||
|
)
|
|||
|
$services = Get-Service -ComputerName $MachineNames -Name 'Alkami Nag Service' | Select-Object MachineName, Status
|
|||
|
|
|||
|
[array]$runningServices = $services | Where-Object { $_.Status -eq "Running"}
|
|||
|
|
|||
|
$runningServices | ForEach-Object { Write-Host $_.MachineName "is running nag" }
|
|||
|
|
|||
|
if ($runningServices.Count -gt 1) {
|
|||
|
|
|||
|
throw "There was more than one Nag Service running"
|
|||
|
}
|
|||
|
|
|||
|
if ($runningServices.Count -eq 0) {
|
|||
|
throw "There are no servers running nag!"
|
|||
|
}
|
|||
|
|
|||
|
Write-Host "Nag is running successfully"
|
|||
|
}
|
|||
|
|