WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!
$Servers = Get-Content MyList.txt
Get-WmiObject Win32_Service -Filter "StartName LIKE "domain\\%" -ComputerName $Servers |
Select-Object Name, StartName, Caption | Export-Csv c:\test.csv -NoTypeInformation
Alternatively, you can manually loop, which is perhaps a bit more fault tolerant:Get-Content MyList.txt | ForEach-Object {
Get-WmiObject Win32_Service -Filter "StartName LIKE "domain\\%" -ComputerName $_
} | Select-Object Name, StartName, Caption | Export-Csv c:\test.csv -NoTypeInformation
I moved your Where-Object filter into the Filter parameter in the WMI query, it's a bit more efficient, if you get your head around the syntax :) % is equivalent to *, and we have to escape \ with another \.Get-Content MyList.txt | ForEach-Object {
Get-WmiObject Win32_Service -Filter "StartName LIKE 'domain\\%'" -ComputerName $_
} | Select-Object Name, StartName, Caption | Export-Csv c:\test.csv -NoTypeInformation
Chris
Get-Content MyList.txt | ForEach-Object {
Get-WmiObject Win32_Service -Filter "StartName LIKE 'domain\\%'" -ComputerName $_
} | Select-Object SystemName, Name, StartName, Caption | Export-Csv c:\test.csv -NoTypeInformation
Chris
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.