如何利用命令行管理SharePoint Feature?

【如何利用命令行管理SharePoint Feature?】分享给互联网技能从业者学习和参考。

一般情况下对IT管理者来说,在SharePoint Farm中维护Feature,更喜欢使用命令行实现,这样可以省去登录到具体站点的操作。比如IT接到end user的一个需求,要开启Site Collection Feature,如果直接操作就要登录site collection-> Site Setting找到Feature点击执行enabledisable,要是使用命令行直接输入命令和网站会更快捷。

下面我们就以SharePoint 2013为例,看下对于Feature的enable、disable、get、install、uninstall的命令都要怎么执行:

Install Feature 登录SharePoint Server,将build好的Feature先copy到SharePoint安装目录"…Program FilesCommon Filesmicrosoft sharedWeb Server Extensions15TEMPLATEFEATURES";

Administrator方式打开SharePoint 2013 Management Shell,输入命令并执行;

Install-SPFeature-path "Feature Folder Name"

此时登录一个site collection,Site Settings-> Site Features,可以看到install的Feature,默认是disable状态。

Enable Feature 仍然是Administrator方式打开SharePoint2013 Management Shell,输入命令并执行;

Enable-SPFeature-identity "Feature Name" - URL"Site Collection URL"

登录到Site Collection,Site Settings中查看Feature情况,成功被启用。

Disable Feature Administrator方式打开SharePoint2013 Management Shell,输入命令并执行,在弹出的确认执行对话中输入"Y"执行;

Disable-SPFeature -identity"FeatureName" - URL "Site CollectionURL"

登录到Site Collection,Site Settings中查看Feature情况,成功被禁用。

Get Feature Administrator方式打开SharePoint2013 Management Shell,输入命令并执行,可以查询到当前site下所有的Feature。

Get-SPSite "SiteCollection URL" | Get-SPWeb -Limit ALL |%{Get-SPFeature -Web $_ } | Select DisplayName,ID -Unique

在SharePoint2013 Management Shell中输入下面命令可以知道部署到Site中的Feature都有哪些。

Get-SPFeature -Limit ALL | Where-Object {$_.Scope -eq"SITE"}

Uninstall Feature Administrator方式打开SharePoint2013 Management Shell输入命令行,在弹出确认提示中输入"Y",并执行;

Uninstall-SPFeature-identity "Feature Folder Name"-force

登录SharePoint网站,查看Feature情况,已经被成功卸载。

 

如何利用命令行管理SharePoint Feature?