Enable-SPFeature

 

適用版本: SharePoint Foundation 2010, SharePoint Server 2010

上次修改主題的時間: 2016-10-12

啟用位在指定範圍上的已安裝 SharePoint 功能。

Syntax

Enable-SPFeature [-Identity] <SPFeatureDefinitionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-PassThru <SwitchParameter>] [-Url <String>] [-WhatIf [<SwitchParameter>]]

詳細描述

Enable-SPFeature Cmdlet 會啟用指定範圍上的已安裝功能。該功能若為伺服器陣列功能,即不需要任何 URL。否則,請提供該功能啟用所在的 URL,其即可根據功能定義在適當的範圍內啟用。

除非提供 PassThru 參數,否則此 Cmdlet 沒有輸出,在此情況下會傳回新近啟用之功能的 SPFeatureDefinition 物件。

注意

若嘗試在伺服器陣列範圍的功能上使用 Url 參數,就會收到下列錯誤訊息:
「<功能名稱>」功能適用於整個伺服器陣列;Url 參數無法與伺服器陣列範圍的功能搭配使用。

如需 Windows PowerShell for SharePoint 產品的權限及最新資訊,請參閱線上說明文件 (https://go.microsoft.com/fwlink/?LinkId=163185)。

Parameters

參數 必要 輸入 描述

Identity

必要

Microsoft.SharePoint.PowerShell.SPFeatureDefinitionPipeBind

指定要啟用的功能或 GUID 名稱。

此類型必須是位在 14\Template\Features 資料夾中的功能資料夾名稱或 GUID 名稱,格式為 21d186e1-7036-4092-a825-0eb6709e9281。

AssignmentCollection

選用

Microsoft.SharePoint.PowerShell.SPAssignmentCollection

為能適當處置物件而管理物件。使用 SPWebSPSite 等物件可能會耗用大量的記憶體,因此在 Windows PowerShell 指令碼中使用這些物件時,必須適當地管理記憶體。您可以使用 SPAssignment 物件將物件指派給變數,並在不需要時處置這些物件,以釋放記憶體。使用 SPWebSPSiteSPSiteAdministration 物件時,若未使用指派集合或 Global 參數,將會自動處置這些物件。

注意

使用 Global 參數時,所有物件會包含在全域儲存區內。若未立即使用物件,或未使用 Stop-SPAssignment 命令處置物件,將會發生記憶體不足的狀況。

Confirm

選用

System.Management.Automation.SwitchParameter

執行命令之前,會先提示您進行確認。如需詳細資訊,請輸入下列命令:get-help about_commonparameters

Force

選用

System.Management.Automation.SwitchParameter

強制啟動功能。這會重新執行與該功能相關聯的所有自訂程式碼。

PassThru

選用

System.Management.Automation.SwitchParameter

若提供,則 Cmdlet 會在啟用之後輸出功能定義物件。

Url

選用

System.String

指定要對其啟動功能的 Web 應用程式、網站集合或網站的 URL。

此類型必須是有效的 URL,例如 http://server_name。

WhatIf

選用

System.Management.Automation.SwitchParameter

顯示訊息描述命令效果,而非描述命令執行的效果。如需詳細資訊,請輸入下列命令:get-help about_commonparameters

輸入類型

傳回類型

Example

--------------範例 1-----------------

Enable-SPFeature -identity "MyCustom" -URL http://somesite

此範例會啟用位在 http://somesite"MyCustom" 網站範圍 SharePoint 功能。

--------------範例 2-----------------

$w = Get-SPWeb http://somesite/myweb | ForEach{ $_.URL }

Get-SPFeature -Web $w |%{ Enable-SPFeature -Identity $_ -URL $w}

此範例會啟用位在 http://somesite/myweb 之子網站的所有 SharePoint 功能。

See Also

Reference

Disable-SPFeature
Install-SPFeature
Uninstall-SPFeature
Get-SPFeature