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.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
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