New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Invoke-WebRequest : Unauthorized

Votes:

0

Your Vote:

Up

Down

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 by  robertnenz (0) 1

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



3 Replies

Votes:

0

Your Vote:

Up

Down

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

Your Vote:

Up

Down

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

Created on Jun 13, 2019 2:07:56 AM by  robertnenz (0) 1



Votes:

0

Your Vote:

Up

Down

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]



Please log in or register to enter your reply.


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.