如何用命令行管理SharePoint Feature?


一般情況下對IT管理者來說,在SharePoint Farm中維護Feature,更喜歡使用命令行實現,這樣可以省去登錄到具體站點的操作。比如IT接到end user的一個需求,要開啟Site Collection Feature,如果直接操作就要登錄site collection-> Site Setting找到Feature點擊執行enable\disable,要是使用命令行直接輸入命令和網站會更快捷。

 

下面我們就以SharePoint2013為例,看下對於Featureenabledisablegetinstalluninstall的命令都要怎么執行:

  • Install Feature
  1. 登錄SharePoint Server,將build好的FeaturecopySharePoint安裝目錄"…\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES"

Machine generated alternative text:Home 0 。 p , Downloads Recent places View Share ram F刂旺 、 Ccmmcn F 刂 “ 、 m 了 rc “ 以 shared 、 Server Extensicn"AIY,TEMPLÅTCvFEATURi Name MruDocsWebPart My Custom Feature Date modified 7 以 1 / 2m5426pM 2 2m6 2 : 51 PM 7 以 2m5 壽 26PM 7 1 / 2m5 山 26 PM Size File folder Filefolder File , 以 d “ File folder

  1. Administrator方式打開SharePoint 2013 Management Shell,輸入命令並執行;

Install-SPFeature-path "Feature Folder Name"

Machine generated alternative text:Admlnlstrator: SharePoint 2013 Management Shell S C : XU s e s Xadm in is t rat 0 , . . DEMO > 丨 n s t a I I —SPFeature —path Cus t 0 Fe at ' isplayNam Cus t 0 Feature r664dd76 一 3 5 e f 一 4g14 —be64 Compat i bilityL e e —c a852879 ddI 4

  1. 此時登錄一個site collectionSite Settings-> Site Features,可以看到installFeature,默認是disable狀態。

Machine generated alternative text:, ' htt 卩 以 1 丷 ' . 0 product.com ite , e 以 tur 酊 」 以 yo 」 t 1 , 'St 以 1 以 叩 : 丨 以 yo 」 t 1 S/ManageFeatures.aspx 會 司 D004vE5 Governmance Automation C Site Settings , ' d em 0 H om e Compliance G uard n SharePoint Following Content Enable users to follow documents or sites. FrankSF2ü13Feature Featurel Getting Started Provides a tile View experience for common SharePOint site actions. Hold , ' Site Features Newsfeed OneDrlve Sltes System ACCOU nt · SHARE FOLLOW Deactivate Activate Deactivate Actlve Actlve

  • Enable Feature
  1. 仍然是Administrator方式打開SharePoint2013 Management Shell,輸入命令並執行;

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

Machine generated alternative text:S C : XU s e rs Xadm in is t rat 0 , . . DEMO > Enable—SPFeature . C e S /f e at ' S C : XU s e rs Xadm in is t rat 0 , . . DEMO > —identity Cus t 0 Fe at '

  1. 登錄到Site CollectionSite Settings中查看Feature情況,成功被啟用。

Machine generated alternative text:· , ' htt 卩 以 1 丷 ' produ 〔 t 工 om ite , t 」 r 」 ℃ 」 t 1 亓 M n 」 EFe t 」 re 氫 叩 : . 0 0 , ' Site Features , ' demo . Home Newsfeed OneDrlve Sltes System ACCOU nt · SHARE FOLLOW 會 司 D004vE5 SharePoint G Overn m a n 0 1 i a n G u a rd i a n Site Settings Deactivate Deactivate Deactivate Actlve Actlve Actlve Enable users to follow documents or sites. FrankSP2013Feature Featurel Getting Started Provides a tile View experience for common SharePOint site actions.

  • Disable Feature
  1. Administrator方式打開SharePoint2013 Management Shell,輸入命令並執行,在彈出的確認執行對話中輸入"Y"執行;

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

Machine generated alternative text:S C : XU s e rs Xadm in is t rat 0 , . . DEMO > Disable—SPFeature U . C e S /f e at ' 0 n f 0 u S 0 u t 0 t h is t n ? —identity Cus t 0 Fe at ' erforming t he operation is —S PFe at " 0 n target b Scope ttp : / / " " " . product . c m/s it e s /f e at ure f 6 64dd76 一 3 5 e f 一 4g14 一 be64 一 ca8s2879dd14 丨 15 " [ Y ] Y e s [ R ] Y e s t 0 R I I [ N ] No [ ] NO t 0 R 11 [ S ] Suspend [ ? ] Help ( de f au It is ' 、 " ) : Y S C : XU s e rs Xadm in is t rat 0 , . . DEMO >

  1. 登錄到Site CollectionSite Settings中查看Feature情況,成功被禁用。

Machine generated alternative text:, ' http://www. product.com/sites/featuré_layouts/l 亓 M n 」 eFe ure ; 叩 : . 0 丨 會 司 D004vE5 Governmance Automation C 00 n ce G uard n Site Settings SharePoint Following Content 0 , ' Site Features , ' demo Home Newsfeed OneDrlve Sltes System ACCOU nt · SHARE FOLLOW Deactivate Activate Deactivate Actlve Actlve Enable users to follow documents or sites. FrankSP2013Feature Featurel Getting Started Provides a tile View experience for common SharePOint site actions.

  • Get Feature
  1. Administrator方式打開SharePoint2013 Management Shell,輸入命令並執行,可以查詢到當前site下所有的Feature

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

Machine generated alternative text:S C : S e in is t 0 Ge t —S PWe b —Limit R isplayName ikiPageHomePage ebPageLibrary izRppsListTempIates 丨 S S S is t b orkf10wHistoryList eportListTempIate WS e d C t FO 0 t e dL in kS is t oCodeWorkf IowLibrary 0110WingContent ySiteMicroB10g urueysList , . idL is t an t t as kS is t in kS is t obi1ityRedirect 0 rkf 10 "Pro c e s s is t as kS is t eamCo Ilab ccSucRddRccessRpp as e We b it e Fe e dCo n t , . 01 le , . orkf 10 as k ierarchyTasksList DSFeature as kL is t Ne WS Fe e d n n 0 C e me n t S is t ettingStarted 0 rkf 10 WS e ru ic e S t 0 re it e Fe e d 0 n t t S is t us t 0 is t ocumentLibrary IS C us S 10 n S is t ataSourceLibrary ataConnectionLibrary Xt e a IL is t e n t S is t mlFormLibrary 丨 PFS We bFe at ure s S C : S e in is t 0 . DEMO) Ge t —S PS it e 丨 { Get—SPFeature "http://WWW —Web 一 } . product . C m/S e S /f e at S e le c t DisplayName , 丨 D —d8fe 一 c796 —5 2 31 —5 9 3 2 —Ø6e6 —4ea5 一 71g9 —e 5 2 8 —e5Øc —f6øø —6?cd —ø34ø —eb8a —3aId —513 d 一 2g62 —3?e5 一 2d77 —a83e —4ea5 —5 2 6 b —89aØ —63af —9afd 一 r437 —f 2 6 ø —dlce —52d4 —ødø2 —e545 —?e6d —de22 一 e717 一 6a49 —f 3 81 —dbd? 一 9s49 —e c 8 5 一 1 e 1 d 一 13 2 9 —4fec 一 44g2 一 477e —4f9c 一 447a 一 48d4 —4CCC —4da2 —4?5e 一 43r6 —4dcI 一 47g8 —"bl 一 41d3 —4caØ 一 426c 一 4743 —4a?5 一 497e 一 48d4 —42c5 —45aa —4fac —4ffø —4f?e 一 42r3 —46fb —42de —45b3 —4f4f 一 42c6 一 4d32 一 4186 一 43h2 —4e8Ø —43fa 一 423d 一 4r72 一 43r8 一 49g3 一 4s62 一 49d4 —8dad 一 9 f 2 f 一 a972 —ad?l —98Øe —a4ad —Balc —ae9f —8?ab —a895 —9fdø —b465 —Wc? 一 9 6 c 2 —9øbf —b4a8 一 9 f c a —9baØ —a4ad 一 87h6 一 916 3 —b55? 一 8 6 6 e —8bc6 —a41b 一 816 3 一 9 c 6 3 —b544 —aaØ? —aeff 一 897a —9ba8 一 a848 —aal? —b535 —b9dI —b8cb 一 h978 一 972d —b56a —9eØ9 —øI c 19 a6 e "5 3 —Øeb9a6e?Ib18 一 14177c c 5 b3 c 7 一 15 5 ?e 5 7511 øø —2e9øbø31øIb8 —3ø5cf?ø3ø14ø 一 314894de e b3 a 一 3 2 b3535 f bb59 一 3 61 c e de 5 dd?f —4øcøde?bøII? 一 43 f 615 812 ø?a 一 441a41c37ar7 —5Ø6be?59ØIØ2 一 6 51 dl 157g12 ø 一 6a4777scg119 一 714cs96gg1g3 —?4dIdb3fd8a4 一 76 516 6 8 9 e 21 a —?a5c59?dØIØ? —?ea5cØIIabe5 一 8 5 2 bd83 e ø364 一 8 5 3 42 e 8 6 5 dc 8 一 91 bd8 c 315432 一 9393ad6647h1 一 9 46 3 78 c 8 5 øf ø 一 9 81 a2 f f c e 3 Pa 一 9 d5335 ?e f 9 8 d —a44ØØ4ceØIØ4 一 h1c71h62g1g9 —b3?ø199cdøc? —b3968162 d4bI —bab6 f 5 8 46 e 18 —cØ4?ac?5ØIØ5 —cø5?ø99øøIøø —døc?Ib36øIøI —d15cø55øøIø8 —da?a54c5ØIIØ —da?acØ44Ø13Ø —e4?e54aIØ6ØØ —ebe4?5?8ØIØ6 —fø53?Ibbø115 —f28øcdbed3?d ØØbfea?I ØØbfea?I ø65 c 78 be ØØbfea?I ø8 ø6 dl 2 7 ØØbfea?I 2 51 ød?3 f d95 c 9 ?f 3 19 2 e f a95 ØØbfea?I a7a2793e e a2365 øb ØØbfea?I ØØbfea?I ØØbfea?I ØØbfea?I f 41 c c 6 6 8 ØØbfea?I ØØbfea?I ØØbfea?I d2 b9 e c 2 3 9 9 f e 4g2 e 515 315 6 a 5 7311 b?a f 9 c e 21 f 8 8 72 94c 72 f f 13 819 a ØØbfea?I ØØbfea?I 4aec?2Ø? 2 c 6 3 df 2 b 15 as 72 c 6 ØØbfea?I ØØbfea?I ØØbfea?I ØØbfea?I ØØbfea?I ØØbfea?I ØØbfea?I ØØbfea?I ØØbfea?I aØe5aØIØ . DEMO)

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

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

Machine generated alternative text:S C : S e in is t 0 —eq "S 丨 T E " } isplayName as e u ie wWo rkf 10 WS . DEMO) Get —SPFeature —Limit R Whe re —Object ($_.Scop Compat i bilityL e e 一 1 c 5 e —9dø? —93dd —føc4 一 49s1 —4b" 一 22a9 一 6796 —fcb9 —e6ab —Pfaf 一 4a24 —4f3ø 一 4c68 —4d4e 一 418g —Ildc 一 4g76 一 4s19 一 4376 一 4798 —45c5 —4bb? 一 4d47 —4b5b ØØbfea?I ø2464c 6 a ø3bøa3dc ø5891451 ø63 c 2 6 f a ø68 bc 8 3 2 ø?Ide6ød øaf 5 9 8 9 a Øc5Ø4a5c Øc8a9a4? 142 ae 5 f 3 14aafd3a 16 6 3 e e 19 169ØØØ4e —b31ø —baØ4 一 943e 一 81h1 一 8a84 一 8 314 —bøøl —8abØ —bØ5e 一 8 2 f 1 —b31d —9ad? —belb 一 9 e f ø —ba51c3eb?a5? —e 9 ø35 c f 5 43 9 2 —Ve c 5 6 e 6 5 e d4d —ødabd84øbad4 —b6 f 9 8 e 9 91 df 3 —Ø8ØØ2ØØc9a66 —b456 e 9 3146 f e 一 8 5 d91 abe 3 9 f f —cbca5ced?b4f —ØØe62a96ØØ6e 一 2 e 6 2 e 8 8 6 8 b53 —dB e 3 6 b663 bbd —adeb2?cfd9d2 一 2 8 bl 21 b8 df aø SSSearchEndUserHe1pFeature PSMonDatasourceCtype ocationBasedPolicy nhancedTheming e IpLibrary 0 rkf 10 WS fficeWebRpps C awf S it e ocalSiteDirect0FYContFOI P2øIøRuditorMonitor_De1eti.

  • Uninstall Feature
  1. Administrator方式打開SharePoint2013 Management Shell輸入命令行,在彈出確認提示中輸入"Y",並執行;

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

Machine generated alternative text:S C : XU s e rs Xadm in is t rat 0 , . . DEMO > U n in s t a I —f 0 e 0 n f —SPFeature —identity Cus t 0 Feature Help [ ? ] 0 u S 0 u t 0 t h is t n ? erforming t he operation n in S t a I I—S PFe at " 0 n target "Fe at ure De f in it io n / 15 /f 6 64dd76 一 3 5 e f 一 4g14—be 64—c a852879 ddI 4 " [ Y ] Y e s [ R ] Y e s t 0 R I I [ N ] No [ ] NO t 0 R 11 [ S ] Suspend ( de f au It is ' 、 " ) : Y S C : XU s e rs Xadm in is t rat 0 , . . DEMO >

  1. 登錄SharePoint網站,查看Feature情況,已經被成功卸載。

Machine generated alternative text:, ' htt 的 勹 、 丷 ' product.com/sites/featuré_layouts/l 亓 M n 」 eFe ure ; 叩 : . 0 丨 會 司 D004vE5 Governmance Automation C Compliance G uard n Site Settings ShareP01nt Following Content 0 , ' Site Features , ' demo Home Newsfeed OneDrlve Sltes System ACCOU nt · SHARE FOLLOW Deactivate Deactivate Actlve Actlve Enable users to follow documents or sites. Getting Started Provides a tile View experience for common SharePOint site actions.

 

以上就是關於在SharePoint中對Feature執行InstallUninstallEnableDisableGet的命令,感謝閱讀!


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com