1. On the Start menu, click All Programs.
2. Click Microsoft SharePoint 2010 Products.
3. Click SharePoint 2010 Management Shell
Note : You should have SharePoint_Shell_Access role on the configuration database and you should be a member of the WSS_ADMIN_WPG local group on the computer where SharePoint Server 2010 is installed.
Some of the Common Commands and Operations are:
Create Web Application Variable
$webapp = Get-SPWebApplication "http://WebapplicationUrl"
Create SharePoint Site Variable (Instance of SPSite)
$siteurl = "http://MySharePointSite"
$Oursite=new-object Microsoft.SharePoint.SPSite($siteurl)
Here we have created a variable Oursite, which contains an instance of type SPSite. Now you can use it to display all webs in the site collection.
$Oursite.AllWebs more // List all Webs in the Site
Create Service Application Variable
$spapp = Get-SPServiceApplication -Name "ServiceApplicationDisplayName"
Create a Webapplication:
New -SPWebApplication -ApplicationPoolName
Delete WebApplication
Remove-SPWebApplication –identity -URL
Create\Delete a Site Collection:
Create a Site collection:
Get-SPWebTemplate
$template = Get-SPWebTemplate "STS#0"
New-SPSite –Url "
Here $template is a Variable to store the type of template we want to use while creating a site collection.
Delete a Site Collection:
Remove-SPSite –Identity
Here
Back\Restore a content database
To Backup :
Backup -SPFarm -Directory
Backup folder - is a folder to save your backup.
BackupMethod – Can Specify between Full or Differential.
To Restore:
Restore -SPFarm -Directory
If you don’t know the BackupID you can display all the backups using the below command and get the GUID of the Backup.
Get-SPBackupHistory -Directory
You can check all the Backup-Restore Operations Here
Deploy WebPart Soluiton Package
Install -SPWebPartPack -LiteralPath "PathToCABorwspFile" -Name "NameOFWebPart"
PathToCABorwspFile- is the full path to the CAB file that is being deployed.
NameOFWebPart- is the name of the Web Part that is being deployed.
Install Activate and Deactivate Feature using Windows Powershell
Install Feature :
$MyFeatureId = $(Get -SPFeature -limit all where {$_.displayname -eq "myfeatureName"}).Id
Install -SPFeature $MyFeatureId
Activate\Enable Feature :
$singleSiteCollection = Get -SPSite -Identity http://MySingleSiteCollectionURL
Enable -SPFeature $MyFeatureId -Url $singleSiteCollection.URL
Deactivate\Disable Feature :
$singleSiteCollection = Get-SPSite -Identity http://MySingleSiteCollectionURL
Disable -SPFeature $MyFeatureId -Url $singleSiteCollection.URL
Command TO List all the PowerShell Commands
Get-Command –PSSnapin “Get-Command –PSSnapin “Microsoft.SharePoint.PowerShell” format-table name > C:\SP2010_PowerShell_Commands.txt