共用方式為


Enable-SPFeature

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

語法

SiteFeature

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

FarmFeatureDefinition

Enable-SPFeature
    [-Identity] <SPFeatureDefinitionPipeBind>
    [-AssignmentCollection <SPAssignmentCollection>]
    [-Confirm]
    [-Force]
    [-PassThru]
    [-WhatIf]
    [-CompatibilityLevel <Int32>]
    [<CommonParameters>]

Description

Enable-SPFeature Cmdlet 會在指定的範圍啟用已安裝的功能。 如果此功能是伺服器數位功能,則不需要URL。 否則,請提供要啟用功能的 URL,並根據功能定義在適當的範圍啟用它。

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

如果您嘗試在伺服器數位範圍的功能上使用 URL 參數,您會收到下列錯誤訊息:

功能 「<功能名稱>」適用於整個伺服器數位;Url 參數不能與伺服器數位範圍的功能搭配使用。

如需適用於 SharePoint 產品的 Windows PowerShell 權限及最新資訊,請參閱線上文件 SharePoint Server Cmdlet

範例

範例 1

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

此範例會啟用 「MyCustom」 網站範圍的 SharePoint 功能,網址為 https://somesite.

範例 2

C:\PS>$w = Get-SPWeb https://somesite/myweb | ForEach{ $_.URL }
Get-SPFeature -Web $w |%{ Enable-SPFeature -Identity $_ -URL $w}

此範例會啟用子網站中的所有 SharePoint 功能, https://somesite/myweb.

參數

-AssignmentCollection

適用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019

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

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

參數屬性

類型:SPAssignmentCollection
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:True
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-CompatibilityLevel

適用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019

{{填滿 CompatibilityLevel Description}}

參數屬性

類型:Int32
預設值:None
支援萬用字元:False
不要顯示:False

參數集

FarmFeatureDefinition
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-Confirm

適用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019

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

參數屬性

類型:SwitchParameter
預設值:None
支援萬用字元:False
不要顯示:False
別名:cf

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-Force

適用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019

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

注意事項

如果您使用 Update-SPSolution 更新功能,請注意 -Force 此功能將無法運作。 在此情況下,您必須先使用 停用 Disable-SPFeature 功能,然後使用 來啟用它 Enable-SPFeature

參數屬性

類型:SwitchParameter
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-Identity

適用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019

指定要卸載的功能或 GUID 名稱。

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

參數屬性

類型:SPFeatureDefinitionPipeBind
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:1
必要:True
來自管線的值:True
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-PassThru

適用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019

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

參數屬性

類型:SwitchParameter
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-Url

適用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019

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

類型必須是有效的 URL;例如 https://server_name.

參數屬性

類型:String
預設值:None
支援萬用字元:False
不要顯示:False

參數集

SiteFeature
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-WhatIf

適用:SharePoint Server 2010、SharePoint Server 2013、SharePoint Server 2016 SharePoint Server 2019

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

參數屬性

類型:SwitchParameter
預設值:None
支援萬用字元:False
不要顯示:False
別名:無線

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

CommonParameters

此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters