在 SharePoint Server 執行已編寫監視設定指令碼Run scripted monitoring configuration in SharePoint Server

摘要:了解如何使用 Microsoft PowerShell 指令碼和設定檔檔案,以在 SharePoint Server 2016 和 SharePoint 2013 環境下自動備份、還原或變更監視設定。Summary: Learn how to use Microsoft PowerShell scripts and Profile files to automatically back up, restore, or change monitoring settings in a SharePoint Server 2016 and SharePoint 2013 environment.

已編寫監視設定指令碼使用 PowerShell 指令碼和 XML 檔案,亦稱為 設定檔,以在 SharePoint Server 2016 環境下備份、還原或設定監視設定。如需已編寫監視設定指令碼的詳細概念資訊,請參閱<SharePoint Server 中的已編寫監視設定指令碼概觀>。Scripted monitoring configuration uses PowerShell scripts and XML files, which are known as Profiles, to back up, restore, or configure monitoring settings in the SharePoint Server 2016 environment. For more conceptual information about scripted monitoring configuration, see Overview of scripted monitoring configuration in SharePoint Server.

注意

您必須下載 PowerShell 指令碼以備份、還原或變更伺服器陣列監視設定。當您執行 BackupMonitoringSettings.ps1 SharePoint Server 指令碼時,您會建立備份設定檔,能以此建立其他設定檔。You must download the PowerShell scripts to back up, restore, or change the farm monitoring settings. When you run the BackupMonitoringSettings.ps1 SharePoint Server script, you create the backup Profile from which you can create other Profiles.

使用 BackupMonitoringSettings.ps1 指令碼Use the BackupMonitoringSettings.ps1 script

您可以使用已編寫監視設定指令碼,以備份伺服器陣列的監視設定。您應在完成伺服器陣列部署完成後進行此操作,以確保您可以將伺服器陣列還原為原始設定。您也可以備份在伺服器陣列進行任何變更之前或之後的設定。You can use scripted monitoring configuration to back up the monitoring settings for the farm. You should do this immediately after you complete the deployment of the farm to make sure that that you can restore the farm to its original settings. You can also back up the settings before or after any changes to the farm.

重要

您可以在 TechNet Gallery 的已編寫監視設定指令碼 - BackupMonitoringSettings 中取得此指令碼。This script is available on the TechNet Gallery at Scripted Monitoring Configuration - BackupMonitoringSettings.

若要備份伺服器陣列監視設定To back up the farm monitoring settings

  1. 確認您具備下列成員身分:Verify that you have the following memberships:

    • SQL Server 執行個體上的 securityadmin 固定伺服器角色。securityadmin fixed server role on the SQL Server instance.

    • 所有要更新之資料庫上的 db_owner 固定資料庫角色。db_owner fixed database role on all databases that are to be updated.

    • 正在執行 PowerShell Cmdlet 之所在伺服器上的系統管理員群組。Administrators group on the server on which you are running the PowerShell cmdlets.

      系統管理員可以使用 Add-SPShellAdmin Cmdlet 授與使用 SharePoint Server Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server cmdlets.

      注意

      如果您不具備上述權限,請連絡安裝程式系統管理員或 SQL Server 系統管理員要求權限。如需 PowerShell 權限的其他資訊,請參閱 Add-SPShellAdminIf you do not have permissions, contact your Setup administrator or SQL Server administrator to request permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.

  2. 啟動 SharePoint 管理命令介面。Start the SharePoint Management Shell.

  3. 在 PowerShell 命令提示字元中,輸入下列命令:At the PowerShell command prompt, type the following command:

    .\BackupMonitoringSettings.ps1 "<ProfileFolder>"
    

    其中:Where:

    • <ProfileFolder> 是設定檔資料夾的完整路徑,您想以此儲存備份設定。XML 檔案名稱是「BackupSetting_[日期] @ [時間].xml」形式。每次執行指令碼時,都會建立一個新的檔案。<ProfileFolder> is full path of the folder that you want to store the backup settings Profile in. The XML file name is in the form "BackupSetting_[DATE] @ [Time].xml". The script will create a new file every time that it is run.

使用 AlterMonitoringSettings.ps1 指令碼Use the AlterMonitoringSettings.ps1 script

您可以使用已編寫監視設定指令碼,以變更或還原伺服器陣列的監視設定。若要變更設定,請建立備份設定檔的複本,並在複本內更改設定以建立新的設定檔。若要套用新設定檔的新設定,請執行 AlterMonitoringSettings.ps1 指令碼,並指定您想要使用的特定設定檔的路徑。如需如何建立設定檔的相關詳細資訊,請參閱 SharePoint Server 中的設定檔結構描述參照You can use scripted monitoring configuration to change or restore the monitoring settings for the farm. To change the settings, create a copy of the backup Profile and change the settings in the copy to create a new Profile. To apply the settings in the new Profile, run the AlterMonitoringSettings.ps1 script and specify the path of the specific Profile you want to use. For more information about how to create Profiles, see Profile schema reference in SharePoint Server.

重要

您可以在 TechNet Gallery 的已編寫監視設定指令碼 - AlterMonitoringSettings 中取得此指令碼。This script is available on the TechNet Gallery at Scripted Monitoring Configuration - AlterMonitoringSettings.

還原設定Restore settings

您可以使用已編寫監視設定指令碼,以隨時還原伺服器陣列的監視設定。您可以將設定還原至任何有對應設定檔的值。You can use scripted monitoring configuration to restore the monitoring settings for the farm at any time. You can restore the settings to any values for which you have a corresponding Profile.

若要還原伺服器陣列監視設定To restore the farm monitoring settings

  1. 確認您具備下列成員身分:Verify that you have the following memberships:

    • SQL Server 執行個體上的 securityadmin 固定伺服器角色。securityadmin fixed server role on the SQL Server instance.

    • 所有要更新之資料庫上的 db_owner 固定資料庫角色。db_owner fixed database role on all databases that are to be updated.

    • 正在執行 PowerShell Cmdlet 之所在伺服器上的系統管理員群組。Administrators group on the server on which you are running the PowerShell cmdlets.

      系統管理員可以使用 Add-SPShellAdmin Cmdlet 授與使用 SharePoint Server Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server cmdlets.

      注意

      如果您不具備上述權限,請連絡安裝程式系統管理員或 SQL Server 系統管理員要求權限。如需 PowerShell 權限的其他資訊,請參閱 Add-SPShellAdminIf you do not have permissions, contact your Setup administrator or SQL Server administrator to request permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.

  2. 啟動 SharePoint 管理命令介面。Start the SharePoint Management Shell.

  3. 在 PowerShell 命令提示字元處,導覽至存有您下載 BackupMonitoringSettings.ps1AlterMonitoringSettings.ps1 指令碼的資料夾。At the PowerShell command prompt, navigate to the folder that you downloaded the BackupMonitoringSettings.ps1 and AlterMonitoringSettings.ps1 scripts to.

  4. 在 PowerShell 命令提示字元中,輸入下列命令:At the PowerShell command prompt, type the following command:

    .\AlterMonitoringSettings.ps1 "<ProfilePath>"
    

    其中:Where:

    • <ProfilePath> 是設定檔資料夾的完整路徑,您想以此還原伺服器陣列的監視設定。<ProfilePath> is full path of the backup Profile that you want to use to restore the monitoring settings for the farm.

套用設定變更Apply settings changes

您可以使用已編寫監視設定指令碼,以變更伺服器陣列的監控設定。若要變更設定,請執行 RestoreMonitoringSettings.ps1 指令碼,並指定您想要使用的特定設定檔的路徑。如需如何建立設定檔的相關詳細資訊,請參閱 SharePoint Server 中的設定檔結構描述參照You can use scripted monitoring configuration to change the monitoring settings for the farm. To change the settings, run the RestoreMonitoringSettings.ps1 script and specify the path of the specific Profile that you want to use. For more information about how to create Profiles, see Profile schema reference in SharePoint Server.

若要套用監控設定變更至伺服器陣列To apply monitoring settings changes to the farm

  1. 確認您具備下列成員身分:Verify that you have the following memberships:

    • SQL Server 執行個體上的 securityadmin 固定伺服器角色。securityadmin fixed server role on the SQL Server instance.

    • 所有要更新之資料庫上的 db_owner 固定資料庫角色。db_owner fixed database role on all databases that are to be updated.

    • 正在執行 PowerShell Cmdlet 之所在伺服器上的系統管理員群組。Administrators group on the server on which you are running the PowerShell cmdlets.

    • 請以高於上述基本要求新增必要的成員資格。Add memberships that are required beyond the minimums above.

      系統管理員可以使用 Add-SPShellAdmin Cmdlet 授與使用 SharePoint Server Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server cmdlets.

      注意

      如果您不具備上述權限,請連絡安裝程式系統管理員或 SQL Server 系統管理員要求權限。如需 PowerShell 權限的其他資訊,請參閱 Add-SPShellAdminIf you do not have permissions, contact your Setup administrator or SQL Server administrator to request permissions. For additional information about PowerShell permissions, see Add-SPShellAdmin.

  2. 啟動 SharePoint 管理命令介面。Start the SharePoint Management Shell.

  3. 在 PowerShell 命令提示字元處,導覽至存有您下載 BackupMonitoringSettings.ps1AlterMonitoringSettings.ps1 指令碼的資料夾。At the PowerShell command prompt, navigate to the folder that you downloaded the BackupMonitoringSettings.ps1 and AlterMonitoringSettings.ps1 scripts to.

  4. 在 PowerShell 命令提示字元中,輸入下列命令:At the PowerShell command prompt, type the following command:

    .\AlterMonitoringSettings.ps1 "<ProfilePath>"
    

    其中:Where:

    • <ProfilePath> 是設定檔資料夾的完整路徑,您想以此設定伺服器陣列的監控設定。<ProfilePath> is full path of the specific Profile that you want to use to configure the monitoring settings for the farm.

另請參閱See also

概念Concepts

SharePoint Server 中的已編寫監視設定指令碼概觀Overview of scripted monitoring configuration in SharePoint Server

SharePoint Server 中的設定檔結構描述參照Profile schema reference in SharePoint Server