PowerShell for Windows Admins

Sep 6 2013   2:18AM GMT

Multiple services on multiple servers–another way

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

A potentially simpler way to solve the issue of multiple servers and multiple services is to use a hash table

$data = @{
“server02” = “BITS”, “NtFrs”, “MSMQ”, “Kdc”;
“exch10” = “MSExchangeAB”, “W32Time”, “W3SVC”

foreach ($server in $data.Keys){
Get-Service -ComputerName $server -Name ($data[$server]) |
select @{N=”Server”; E={$server}}, Status, Name, DisplayName

The data structure is a bit more intuitive as you can see the direct link between the server and its list of services.

A version using PSObjects is available on the forum – http://powershell.org/wp/forums/topic/help-to-output-array/

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: