What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Invoke-WebRequest : Unauthorized

Votes:

0

I am trying to connect to historic data via this URL, which contains my custom date range (last 30 days) and creds.

 $prtgurl = "$PRTGHost/api/historicdata.csv?id=$SensorID&avg=3600&sdate=$StartDate2&edate=$EndDate2&$cred"
 $request = Invoke-WebRequest -Uri $prtgurl -MaximumRedirection 0 -ErrorAction Ignore

I always get this error, which I cant get past. Any suggestions would be great.

Invoke-WebRequest : Unauthorized
+ ...  $request = Invoke-WebRequest -Uri $prtgurl -MaximumRedirection 0 -Er ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

invoke-webrequest prtg-network-monitor-8-x unauthorized

Created on Jun 12, 2019 3:12:20 AM

Last change on Jun 12, 2019 4:28:52 AM by  Sven Roggenhofer [Paessler Technical Support]



3 Replies

Votes:

0

Hi there,

According to the error message "Unauthorized", the credentials are not correct. What does the "$cred"-variable look like?

Best regards.

Created on Jun 12, 2019 5:34:02 AM by  Dariusz Gorka [Paessler Support]



Votes:

0

like this $cred = New-Credential -UserName xxxx -Password xxxxxx

Created on Jun 13, 2019 2:07:56 AM



Votes:

0

Hi there,

I am afraid that this won't work. Changing the "$prtgurl"-variable this way should work:

"$PRTGHost/api/historicdata.csv?id=$SensorID&avg=3600&sdate=$StartDate2&edate=$EndDate2&username=XXXXXXX&password=XXXXXX"

Best regards.

Created on Jun 13, 2019 8:24:14 AM by  Dariusz Gorka [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.