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.

  • Do we need to add Headers? I am getting 401 error for: Invoke-WebRequest -Uri "DownloadURL" -OutFile "LocalPath" -Credential $cred – renjit Mar 17 at 11:22
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, privacy policy and cookie policy

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