Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

invoke-webrequest with an internal sharepoint page

$
0
0

Hi

I am trying to capture the html of a page in sharepoint 2007 (Win 2008 r2 ) using powershell. I have tried the following code:

$username=”ldelpo01
$password=”yyy”

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} –Uri "http://xxx.Departments/SharedServices/Customer%20Feedback%20Submissions/Customer%20Feedback%20Submission%20-%20DE973C08-1723-48DB-82C1-3F40DEBD6479"–outfile test.txt

The error I receive is :

Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:6 char:1
+ Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64Aut ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

I have read that there is a process to auth and sometimes it needs 2 requests (get and post) and headers but it didnt give any examples.

I have been fighting with this for a couple of days and cant figure it out.

Any help would be appreciated

Luis


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>