List AOS services with colors

Here I have a little Powershell script, written mainly for demonstration purposes, nevertheless it does its job and may be useful to somebody.

It connects to any number of servers, finds Dynamics AX AOS services there and shows them in green or red, depending on whether they’re running or not.

$listOfComputers = 'Server1','Server2'
 
$listOfComputers `
    | % {gsv aos* -comp $_ `
        | % {Write-Host $_.DisplayName -f @('Green', 'Red')[$_.Status -ne 'Running']}}

Output:

AOS service colors

Hail Powershell!