2

我在安装了 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

但是,我不确定如何执行异常提示的操作。

4

2 回答 2

0

啊...看起来您正在尝试删除 Web 服务正在使用的 URL...

于 2011-03-30T17:20:35.190 回答
0

事实证明,我忽略了退出默认条​​目的另一种方法:

$webApplication.AlternateUrls.SetResponseUrl($newAltURL)


[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.SetResponseUrl($newAltURL)

            $webApplication.AlternateUrls.Update($true)
       }
    }
}
于 2011-04-12T21:29:36.427 回答