0

I am getting below error while running below command for SharePoint url from powershell.

Invoke-WebRequest -UseDefaultCredentials -Uri http://spurl

Invoke-WebRequest : The remote server returned an error: (401) Unauthorized.

1
  • Do we need to add Headers? I am getting 401 error for: Invoke-WebRequest -Uri "DownloadURL" -OutFile "LocalPath" -Credential $cred
    – renjit
    Mar 17, 2019 at 11:22

1 Answer 1

2

It's a late answer, but i hope this can help someone else with the same problem:

        $username = "your domain/username"
        $password = ConvertTo-SecureString "your password" -AsPlainText -Force
        $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
        Invoke-WebRequest -Credential $cred -Uri http://spurl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.