Link to home
Start Free TrialLog in
Avatar of EntAppDevTeam
EntAppDevTeamFlag for United States of America

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)
}

Open in new window


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?
Avatar of Dale Harris
Dale Harris
Flag of United States of America image

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?
Avatar of EntAppDevTeam

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
Avatar of Dale Harris
Dale Harris
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.