I want to check that a service is started on multiple servers.
I get the information successfully with a single line to each remote computer individually:
get-service -ComputerName csgp025 | Where-Object {$_.displayname -like "*lync*"} | ft
This is the script I am experimenting with to check a list of servers:
#Check that SBA services are up
#CSV contains one column "SBA"
$sbas = Import-Csv "C:\data\SBAs.csv"
foreach ($sba in $sbas)
{
get-service -ComputerName $sba | Where-Object {$_.displayname -like "*lync*"} | ft
}
I get this error for each server in the CSV file:
get-service : Cannot open Service Control Manager on computer '@{SBA=csgp025}'. This operation might require other privileges.
At C:\Scripts\Check-SBAServices.ps1:7 char:1
+ get-service -ComputerName $sba | Where-Object {$_.displayname -like "*lync*"} | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Service], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand
Since it works with a single line to each server I don't think it is a permission issue. Most likely my syntax or data file?