Saturday, 9 November 2013

Common and Useful PowerShell commands for SharePoint 2010/2013

Useful PowerShell commands for SharePoint

Working with SharePoint solutions
1.       Add Solution
Add-SPSolution c:\mysolution.wsp
2.       Install SharePoint Solution
Install-SPSolution  –Identity mysolution.wsp  –WebApplication http://spsite  -GACDeployment
3.       Update solution
Update-SPSolution –Identity mysolution.wsp –LiteralPath c:\ mysolution.wsp –GACDeployment
4.       Uninstall Solution
Uninstall-SPSolution –Identity mysolution.wsp –WebApplication  http://spsite  
5.       Remove solution
Remove-SPSolution –Identity MySharePointSolution.wsp
Working with SharePoint Features
1.       Install feature
Install-SPFeature “Feature Folder Name”
2.       Enable Feature
Enable-SPFeature “Feature Folder Name”  -Url  http://spsite
3.       Disable Feature
Disable-SPFeature “Feature Folder Name”  –Url  http://spsite
4.       Uninstall Feature
Uninstall-SPFeature “Feature Folder Name”
5.       Get All Features in the Farms
In result it will provide you all feature with Display name, Id and scope. You can apply sorting, grouping on it
Get-SPFeature | Sort -Property DisplayName/id/scope
Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope

6.       Get All  Features in Site Collection
Get-SPFeature -Site http://yousitecolletion
7.       Get All features in Web 
Get-SPFeature -Web http://youweburl
Back-Up and Restore Site Collection
1.       Back Up Site Collection
             Backup-SPSite -Identity http://yousitecolletion -Path  c:\sitebackup.bak -Force
2.       Restore SiteCollection
Restore-SPSite -Identity http://yousitecolletion -Path c:\sitebackup.bak  -Force