Multiple services on multiple servers–another way

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/

This entry was posted in PowerShell V3. Bookmark the permalink.

One Response to Multiple services on multiple servers–another way

  1. Pingback: hashtable from Richard Siddaway | becknspace

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s