EntAppDevTeam
asked on
PowerShell Get-EventLog error "network path not found"
$SvrList = get-content “c:\scripts\servers.txt”
Write-host “Print Event Compiler”
$UsrStartDate = Read-Host “Enter the beginning date in MM/DD/YYYY format please:”
$UsrEndDate = Read-Host “Enter the ending date in MM/DD/YYYY format please:”
$begindate = get-date ($UsrStartDate)
$enddate = get-date ($UsrEndDate)
foreach ($server in $SvrList)
{
$savePath = "C:\Scripts\" + ($server) + "-printjobs.csv"
get-eventlog system -computer $server -before $enddate -after $begindate | where-Object {$_.EventID -eq 10} | export-csv -path ($savePath)
}
The above code executes flawlessly on most of our servers, but for some reason I get the network path not found eror with a few of them. I am running this script as a domain admin, remote registry is enabled and automatic, firewall is more or less disabled. Any ideas?
I would throw in a test-connection command to make sure it has a solid connection to the ones that are offline. Unless that's not your issue?
ASKER
I have a solid connection between the two and can ping and resolve hostnames successfully. I have tested connecting to the event log through the eventviewer and I receive the error rpc service unavailable.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I resolved this issue with additional research. Points were awarded to DaleHarris for his participation and because the issue did end up being related to a firewall.