I am trying to get my head around Powershell and have the following:
$servers = Get-Content -Path C:\servers.txt
Get-Process -name AVProcess -cn $servers | % where {$_.Status -eq "Running"}
#Export-Csv -path "C:\server-process-sophos.csv"
I get an error, it looks like i cant use the $servers Variable within the parameter computername, also sending to the CSV file is way off. Ideally i'd like to be able to pipe each server name, status of the process into rows in a CSV.
I am trying to return a list of servers which do/dont have that process running or not - so i can see if they have AV installed essentially for an inventory report (this is not good if some dont have AV!!!). How can i best go about this?
Thanks in advance