共用方式為


Install-SPFeature

 

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

上次修改主題的時間: 2015-03-09

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

Syntax

Install-SPFeature [-Path] <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-WhatIf [<SwitchParameter>]]

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

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

詳細描述

Install-SPFeature Cmdlet 會在 Identity 參數中提供功能的 "$env:ProgramFiles\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\ 資料夾相對路徑,以安裝特定的 SPFeature 物件。SharePoint 功能的檔案必須已經以手動方式或使用解決方案安裝程式,先行放在適當的目錄中。

若已提供 AllExistingFeatures,即會掃描檔案系統及所有安裝的新功能。這一般只在部署及升級期間使用。

Parameters

參數 必要 類型 描述

Path

必要

System.String

指定有效的檔案路徑,例如 MyFeature。

功能的路徑必須是 14\Template\Features 目錄的常值路徑。檔案名稱可以使用 Windows 系統支援的任何標準字元。feature.xml 檔案名稱是隱含的,不必提供。

若在磁碟上找不到功能檔案,則會顯示下列錯誤訊息:「在位置 14\Template\Features\<檔案路徑> 找不到 XML 檔案。」

AllExistingFeatures

必要

System.Management.Automation.SwitchParameter

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

ScanForFeatures

必要

System.Management.Automation.SwitchParameter

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

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

強制安裝已安裝的功能。

SolutionId

選用

System.String

指定功能的解決方案 ID。若未提供 SolutionId 參數,就會掃描所有解決方案 ID。

WhatIf

選用

System.Management.Automation.SwitchParameter

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

輸入類型

傳回類型

Example

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

Install-SPFeature -path "MyCustomFeature"

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

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

Install-SPFeature -AllExistingFeatures -Whatif

此範例會顯示檔案系統中可用但未註冊的功能,若執行此命令但不搭配 WhatIf 參數,即會安裝這些功能。此作業一般是在升級程序後完成。

See Also

Reference

Get-SPFeature
Enable-SPFeature
Disable-SPFeature
Uninstall-SPFeature