当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 在 SharePoint 中创建订阅设置服务应用程序

作者:精品下载站 日期:2024-12-14 14:11:23 浏览:12 分类:玩电脑

使用 PowerShell 在 SharePoint 中创建订阅设置服务应用程序


SharePoint 中的订阅设置服务应用程序是什么?那么,SharePoint Apps 平台依赖于 Microsoft SharePoint Foundation 订阅设置服务应用程序。因此,如果您想在SharePoint中使用应用程序,那么创建订阅设置服务应用程序是先决条件。

如何创建订阅设置服务应用程序?

订阅设置服务应用程序只能通过 PowerShell 创建。没有 GUI 来创建此服务应用程序!让我们使用 Windows PowerShell 配置订阅设置服务应用程序。

不要忘记根据您的环境在下面的脚本中更改配置参数,例如服务帐户、数据库名称等。完成后,从 PowerShell ISE 或通过 SharePoint Server 2013 Management Shell 运行此 PowerShell 脚本。

PowerShell 在 SharePoint 中创建订阅设置服务应用程序


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters
$ServiceAppName = "Subscription Settings Service Application"
$AppPoolAccount = "Crescent\SP16-AppPool"
$AppPoolName = "Service Application App Pool"
$DatabaseServer = "SP16-SQL001"
$DatabaseName = "SP16_SubsSett_ServiceApp"

Try {
    #Set the Error Action
    $ErrorActionPreference = "Stop"

    #Check if Managed account is registered already
    Write-Host -ForegroundColor Yellow "Checking if Application Pool Accounts already exists"
    $AppPoolAccount = Get-SPManagedAccount -Identity $AppPoolAccount -ErrorAction SilentlyContinue
    if($AppPoolAccount -eq $null)
    {
        Write-Host "Please Enter the password for the Service Account..."
        $AppPoolCredentials = Get-Credential $AppPoolAccount
        $AppPoolAccount = New-SPManagedAccount -Credential $AppPoolCredentials
    }
 
    #Check if the application pool exists already
    Write-Host -ForegroundColor Yellow "Checking if the Application Pool already exists"
    $AppPool = Get-SPServiceApplicationPool -Identity $AppPoolName -ErrorAction SilentlyContinue
    if ($AppPool -eq $null)
    {
        Write-Host -ForegroundColor Green "Creating Application Pool"
        $AppPool = New-SPServiceApplicationPool -Name $AppPoolName -Account $AppPoolAccount
    }
 
    #Check if the Service application exists already
    Write-Host -ForegroundColor Yellow "Checking if Subscription Settings Service Application exists already"
    $ServiceApplication = Get-SPServiceApplication -Name $ServiceAppName -ErrorAction SilentlyContinue
    if ($ServiceApplication -eq $null)
    {
        Write-Host -ForegroundColor Green "Creating Subscription Settings Service Application..."
        $ServiceApplication = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $AppPoolName -Name $ServiceAppName -DatabaseName $DatabaseName -DatabaseServer $DatabaseServer 
        $Proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $ServiceApplication
        Write-Host -ForegroundColor Green "Subscription Settings Service Application created successfully!"
    }

    #Start service instance 
    $ServiceInstance = Get-SPServiceInstance | Where-Object { $_.TypeName -eq "Microsoft SharePoint Foundation Subscription Settings Service"}
 
    #Check the Service status
    if ($ServiceInstance.Status -ne "Online")
    {
        Write-Host -ForegroundColor Yellow "Starting the Subscription Settings Service Instance..."
        Start-SPServiceInstance $ServiceInstance
    }

}
catch {
    Write-Host $_.Exception.Message -ForegroundColor Red
 }
 finally {
    #Reset the Error Action to Default
    $ErrorActionPreference = "Continue"
 }

这将在 SharePoint 2013 和 SharePoint 2016 中创建订阅设置服务应用程序。

[玩转系统] 使用 PowerShell 在 SharePoint 中创建订阅设置服务应用程序

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯