I have a list of servers. I want to check what all automatic services are not running. I want to store it in array and later display in grid view format. I tried below, but it didn't work.
foreach ($i in $list) {
$Res = @(Get-WmiObject Win32_Service -ComputerName $i | Where-Object {
$_.StartMode -eq 'Auto' -and $_.State -ne 'Running'
} | Select PSComputerName, Name, DisplayName, State, StartMode)
}
$Res | Out-GridView