共用方式為


Install-SPFeature

使用 Feature.xml 檔案安裝 SharePoint 功能。

語法

PathSet

Install-SPFeature
    [-Path] <String>
    [-AssignmentCollection <SPAssignmentCollection>]
    [-CompatibilityLevel <Int32>]
    [-Confirm]
    [-Force]
    [-WhatIf]
    [<CommonParameters>]

AllExistingFeatures

Install-SPFeature
    [-AllExistingFeatures]
    [-AssignmentCollection <SPAssignmentCollection>]
    [-Confirm]
    [-Force]
    [-SolutionId <String>]
    [-WhatIf]
    [<CommonParameters>]

ScanForFeatures

Install-SPFeature
    [-ScanForFeatures]
    [-AssignmentCollection <SPAssignmentCollection>]
    [-Confirm]
    [-Force]
    [-SolutionId <String>]
    [-WhatIf]
    [<CommonParameters>]

Description

此 Cmdlet 包含一個以上的參數集。 您可能只使用一個參數集中的參數,但不可以結合不同參數集的參數。 如需如何使用參數集的詳細資訊,請參閱 Cmdlet 參數集

Install-SPFeature Cmdlet 會藉由在 Identity 參數中提供從版本特定通用 FEATURES 資料夾到功能的相對路徑,來安裝特定的 SPFeature。 如果網站集合處於 14 模式,版本特定的 FEATURES 資料夾為 “$env:ProgramFiles\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES”,如果網站集合處於 15 模式,則為 “$env:ProgramFiles\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES”。 SharePoint 功能的檔案必須已經手動或使用解決方案安裝程式放在適當的目錄中。

如果 AllExistingFeatures 參數的值為 true,則會掃描檔系統,並安裝這兩個 FEATURES 資料夾中的所有新功能。 這通常只會在部署和升級期間使用。

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

範例

範例 1

Install-SPFeature -path "MyCustomFeature"

此範例會在 $env:ProgramFiles\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES\MyCustomFeature/feature.xml 安裝新功能。

範例 2

Install-SPFeature -AllExistingFeatures -Whatif

此範例顯示文件系統上可用的未註冊功能,如果執行此命令時沒有 WhatIf 參數,則會安裝這些功能。 這通常會在升級程序之後完成。

範例 3

Install-SPFeature -path "MyCustomFeature"  -CompatibilityLevel 14

本範例會在 $env:ProgramFiles\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\MyCustomFeature\feature.xml 安裝新功能。

範例 4

Install-SPFeature -path "MyCustomFeature"  -CompatibilityLevel 15

此範例會將新功能安裝在 $env:ProgramFiles\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES\MyCustomFeature\feature.xml。

參數

-AllExistingFeatures

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

掃描現有但未註冊的功能,然後向伺服器陣列註冊這些功能。

參數屬性

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

參數集

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

-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

指定要安裝的功能版本。 若未指定版本,預設會使用 Web 應用程式的 MaxVersion 值。

這個的值可以是 14 或 15。

參數屬性

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

參數集

PathSet
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

強制安裝已安裝的功能。

參數屬性

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

參數集

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

-Path

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

指定驗證的檔案路徑,例如 MyFeature。

功能的路徑必須是 14\Template\Features 目錄的常值路徑。 feature.xml 檔案名稱是隱含的,不必提供。

如果找不到功能的路徑,則會顯示下列錯誤訊息:「找不到位於位置 14\Template\Features\<file path 的 XML 檔案」>。

參數屬性

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

參數集

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

-ScanForFeatures

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

掃描然後顯示功能。 ScanForFeatures 參數不會安裝功能。

參數屬性

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

參數集

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

-SolutionId

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

指定功能的解決方案識別碼。 若未提供 SolutionId 參數,將會掃描所有解決方案識別碼。

參數屬性

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

參數集

AllExistingFeatures
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False
ScanForFeatures
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