powershell检查sharepoint URL

时间:2009-10-07 14:59:37

标签: sharepoint authentication powershell active-directory

我正在尝试编写一个脚本,该脚本遍历一堆sharepoint URL并验证它们是否存在。

从我能找到的内容看起来应该可行:

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

这对我不起作用......我一直在努力:

使用“1”参数调用“DownloadString”的异常:“远程服务器返回错误:(401)未经授权。”

我错过了什么?

1 个答案:

答案 0 :(得分:13)

如果您当前的凭据在Sharepoint站点上有权限,则跳过网络凭据并使用默认凭据,例如:

$webClient.UseDefaultCredentials = $true