Forum Discussion

Deleted's avatar
Deleted
Feb 27, 2018

Sharepoint 2013 and Powershell

Could someone please share the appropriate method to use invoke-webrequest in Powershell 5.0 to pull down an Excel doc from a Sharepoint 2013 site using explicit credentials? Both forms and windows auth are enabled in IIS and the providers for windows auth are negotiate and ntlm. I can't seem to get past a 401 http return code when I use my credentials explicitly. If I use the -usedefaultcredentials on invoke-webrequest under my user context, however, it works fine. Arggg.

  • People, clearly you need an incentive to answer my question. I have a Friends and Family discount code for Columbia Sportswear's website and its family of brands (Sorel, Mountain Hardwear, Prana).  

      • Deleted's avatar
        Deleted

        I'm trying to download a file from our on-premise Sharepoint site. If I use the PS code below, the file downloads OK - either using the default creds (under my user account) or if I explicitly enter my creds using get-credential.

         

        Invoke-WebRequest -uri $fromfile1 -outfile $tofile1 -UseDefaultCredential

        Invoke-WebRequest -uri $fromfile1 -outfile $tofile1 -Credential (Get-Credential)

         

        But I need to have this code run under the local system account. When I enter my creds using get-credential - the same as above - in a PS window running under local system, I get:

         

        Invoke-WebRequest : 401 UNAUTHORIZED

         

Resources