Author Posts

February 19, 2018 at 9:38 pm

I am trying to get a powershell script to reach out to a batch of domain computers and pull the specific information from them and put the information back into a .csv file. The challenge is that I think I need 'permissions' to log into each computer to get that information but I am not sure how that would work with the system names sitting in a txt file. Any suggestions would be appreciated.

$C = Get-Credential
-credential $C
$computernames = Get-Content -Path "c:\scripts\test.txt"
Get-EventLog -ComputerName $computernames -LogName System | Where-Object {$_.EventID -eq "1074" -or $_.EventID -eq "6008" -or $_.EventID -eq "1076"} | sort TimeWritten | ft Machinename, TimeWritten, UserName, EventID, Message | Export-Csv -Path "c:\scripts\appevents.csv"

Andrew

February 19, 2018 at 9:41 pm

The challenge is that I think I need 'permissions' to log into each computer to get that information but I am not sure how that would work with the system names sitting in a txt file. Any suggestions would be appreciated.

Indeed you do. Whatever account you run PowerShell with must have those permissions. Unless PowerShell Remoting is enabled on those computers, there's no universal way to specify credentials to a remote machine. Get-EventLog doesn't support doing so, for example. Typically, you need to run the script as an account which is recognized as an Administrator on the remote machine.

February 19, 2018 at 10:17 pm

I doubt Powershell remoting is installed on any of the systems. If I remove the credentials and log in and run with an admin account on my PC, things should work then? Everything else look good?