Install-SPFeature

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

Syntax

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

Description

This cmdlet contains more than one parameter set. You may only use parameters from one parameter set, and you may not combine parameters from different parameter sets. For more information about how to use parameter sets, see Cmdlet parameter sets.

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

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

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-AssignmentCollection

Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

Type:SPAssignmentCollection
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-CompatibilityLevel

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

這個 的值可以是 14 或 15。

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Confirm

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

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Force

強制安裝已安裝的功能。

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Path

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

The path to feature must be a literal path to the 14\Template\Features directory. The feature.xml file name is implied and does not need to be provided.

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

Type:String
Position:1
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-ScanForFeatures

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

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-SolutionId

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

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-WhatIf

Displays a message that describes the effect of the command instead of executing the command. For more information, type the following command: get-help about_commonparameters

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition