以编程方式更新 SharePoint 默认备用访问映射

发布于 2024-10-17 21:19:02 字数 1724 浏览 4 评论 0原文

我在安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心的憧憬 2024-10-24 21:19:02

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

Ah... it looks like you are trying to remove the URL the Webservice is using...

山色无中 2024-10-24 21:19:02

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

$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)
       }
    }
}

It turns out there's another method for the exiting default entry that I overlooked:

$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)
       }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文