以编程方式更新 SharePoint 默认备用访问映射
我在安装了 SharePoint Services 3.0 的 IIS 服务器上启用 HTTPS,并且希望以编程方式更新单个 Web 应用程序和我的中央管理实例(两者都在同一台计算机上)的默认备用访问映射。这是我到目前为止的代码(Powershell),它添加了 HTTPS 的映射,但在尝试删除原始映射时出现错误。
这是我的代码:
[void][system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint")
$SPWebServiceCollection = new-object Microsoft.SharePoint.Administration.SPWebServiceCollection ([Microsoft.SharePoint.Administration.SPFarm]::Local)
foreach ($SPWebService in $SPWebServiceCollection) {
foreach ($webApplication in $SPWebService.WebApplications) {
Write-Host ('Updating {0}' -f $webApplication.Name)
foreach ($alternateUrl in $webApplication.AlternateUrls) {
$incomingUrl = [System.URI] $alternateUrl.IncomingUrl
$newURL = 'https://{0}{1}' -f $incomingUrl.Authority, $incomingUrl.PathAndQuery
$newAltURL = New-Object Microsoft.SharePoint.Administration.SPAlternateUrl ($newURL, $alternateUrl.UrlZone)
$webApplication.AlternateUrls.Add($newAltURL)
$webApplication.AlternateUrls.Update($true)
$webApplication.AlternateUrls.Remove($alternateUrl) #Throws Exception
$webApplication.AlternateUrls.Update($true)
}
}
}
这是当我尝试删除原始代码时出现的错误:
使用“1”个参数调用“删除”时出现异常:“SharePoint 管理框架中的对象“SPAlternateUrlCollection Name=SharePoint - 1000 Parent=SPFarm Name=SharePoint_Config_8ddd3701-a332-4e79-98e4-fa11c1b6c17c”可能会不会被删除,因为其他对象依赖于它。更新所有这些依赖项以指向 null 或不同的对象,然后重试此操作,依赖对象如下:
SPWebApplication 名称=SharePoint - 1000 父=SPWebService
但是,我不确定该怎么做。异常表明什么。
I'm enabling HTTPS on my IIS server where I have SharePoint Services 3.0 installed and I'd like to programatically update the default alternate access mappings for a single web application and my central administration instance (both on the same machine). Here's the code I have so far (Powershell), it adds a mapping for HTTPS but I get and error when trying to remove the original one.
Here's my code:
[void][system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint")
$SPWebServiceCollection = new-object Microsoft.SharePoint.Administration.SPWebServiceCollection ([Microsoft.SharePoint.Administration.SPFarm]::Local)
foreach ($SPWebService in $SPWebServiceCollection) {
foreach ($webApplication in $SPWebService.WebApplications) {
Write-Host ('Updating {0}' -f $webApplication.Name)
foreach ($alternateUrl in $webApplication.AlternateUrls) {
$incomingUrl = [System.URI] $alternateUrl.IncomingUrl
$newURL = 'https://{0}{1}' -f $incomingUrl.Authority, $incomingUrl.PathAndQuery
$newAltURL = New-Object Microsoft.SharePoint.Administration.SPAlternateUrl ($newURL, $alternateUrl.UrlZone)
$webApplication.AlternateUrls.Add($newAltURL)
$webApplication.AlternateUrls.Update($true)
$webApplication.AlternateUrls.Remove($alternateUrl) #Throws Exception
$webApplication.AlternateUrls.Update($true)
}
}
}
Here is the error I get when I try to remove the original:
Exception calling "Remove" with "1" argument(s): "An object in the SharePoint administrative framework, "SPAlternateUrlCollection Name=SharePoint - 1000 Parent=SPFarm Name=SharePoint_Config_8ddd3701-a332-4e79-98e4-fa11c1b6c17c", could not be deleted because other objects depend on it. Update all of these dependants to point to null or different objects and retry this operation. The dependant objects are as follows:
SPWebApplication Name=SharePoint - 1000 Parent=SPWebService
However, i'm not sure how to do what the exception suggests.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
啊...看起来您正在尝试删除 Web 服务正在使用的 URL...
Ah... it looks like you are trying to remove the URL the Webservice is using...
事实证明,还有另一种我忽略的退出默认条目的方法:
It turns out there's another method for the exiting default entry that I overlooked: