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>]

说明

此 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\<文件路径>中找到 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

指定功能的解决方案 ID。 如果未提供 SolutionId 参数,则会扫描所有解决方案 ID。

参数属性

类型: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