I'm trying to do a quick inventory of what startup account each of my servers is using. I wrote the following script, but its not working. Can someone help?
$servers = get-content 'c:\servers.txt'
foreach ($line in $servers)
{
$result = get-wmiobject win32_service -Computer $line | Select-Object name, startname, startmode
echo "ServerName is" $line $result
}
It doesn't appear to like the $line varible after the -computername. If I put just one server name in there it works