Steps:
- Open the notepad and copy the below script and save the file as ActivateFeature.ps1
Script code:
1: Add-PsSnapin Microsoft.SharePoint.PowerShell
2: $URL= read-host "Enter the URL to activate the feature"
3: $FeatureName = read-host "Enter the feature name to activate"
4: try
5: {
6: Enable-SPFeature –Identity $FeatureName –url $URL -force
7: }
8: catch
9: {
10: write-error "error occured while activating the feature"
11: }
12: # Gets the feature object
13: $feature = Get-SPFeature -Identity $FeatureName
14: if($feature -ne $null)
15: {
16: write-host -Fore Green "Feature Activated"
17: }
18: else
19: {
20: write-host -Fore Red "Feature not Activated"
21: }
- Create a batch file with name "ActivateFeature.bat" and copy the below content to it.
1: cd /d %~dp0
2: powershell -noexit -file ".\ActivateFeature.ps1" "%CD%"
3: pause
Copy the above 2 files created above to the server where you want to
deploy and click the ActivateFeature.bat file from where the execution
starts.
No comments:
Post a Comment