开发者

powershell check sharepoint URLs

开发者 https://www.devze.com 2022-12-08 02:27 出处:网络
I\'m trying to write a script that iterates through a bunch of sharepoint URLs and verifies that they exist.

I'm trying to write a script that iterates through a bunch of sharepoint URLs and verifies that they exist.

From what I can find, it looks like this should work:

$webclient = new-object System.Net.WebClient
$webclient.Credentials = new-object System.Net.NetworkCredential ("username", "password", "domain")
$webpage = $webclient.DownloadString("http://sharepointurl")

This is not working for me ... I keep getting:

Exception calling "DownloadString" with "1" argument(s): "The remote server returned an error: (401) Unauthorized开发者_JAVA技巧."

What am I missing ?


If your current credentials have perms on the Sharepoint site then skip the net credential and just use the default credentials e.g.:

$webClient.UseDefaultCredentials = $true


You can use

(Invoke-webrequest -URI "https://www.yoururl.com").Content

Ref: Display all content with Invoke-WebRequest

0

精彩评论

暂无评论...
验证码 换一张
取 消