Hi All,
I am executing the powershell script Invoke-webrequest for few sharepoint sites.
Among 10 SharePoint sites, 1 sharePoint site gave the output as status code "200" and status description "ok". This is a separate webapplication than the others.
But in other SharePoint sites, the output is "401 - Unauthorized"
However when I added "usedefaultcredentials" i.e the script becomes Invoke-webrequest -usedefaultcredentials, then all the 9 sharePoints are giving output as "ok".
Please let me know why it happens for these 9 sites. how should I make them run successfully giving status code "200" without using "usedefaultcredentials".
Actually the same site is giving 2 different status codes when invoked as webrequest in Powershell. However when I am accessing the site from browser, its asking for the credential.
I am running the below script for the same URL and intermittently it is giving status as "401 Unauthorized" and also sometimes returning as "200 - Ok":
Invoke-webrequest <SiteURL>
Can you please help me with the reason of this intermittent issue for the same site.
Source from TechNet