Sunday, September 12, 2010

SharePoint 2010 PowerShell Commands

To Open the Windows PowerShell Session :
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 -Name [ -Port
] [-HostHeader ] [-URL ][ -ApplicationPoolAccount ]

Delete WebApplication
Remove-SPWebApplication –identity -URL -Confirm

CreateDelete a Site Collection:
Create a Site collection:
Get-SPWebTemplate
$template = Get-SPWebTemplate "STS#0"
New-SPSite –Url "" –OwnerAlias "" –Template $template
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 –GradualDelete
Here is a site Collection Url .

BackRestore a content database
To Backup :
Backup -SPFarm -Directory -BackupMethod -Item [-Verbose]
Backup folder - is a folder to save your backup.
BackupMethod – Can Specify between Full or Differential.

To Restore:
Restore -SPFarm -Directory -RestoreMethod Overwrite -Item [-BackupId] [-Verbose]
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

ActivateEnable Feature :
$singleSiteCollection = Get -SPSite -Identity http://MySingleSiteCollectionURL
Enable -SPFeature $MyFeatureId -Url $singleSiteCollection.URL

DeactivateDisable 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

7 comments:

  1. Happy Additional Year everyone! :)

    ReplyDelete
  2. I recently found this website that I want to share with everyopne as they were a great help when I was
    working on a recent project. I needed to know how to do some stuff in PHP and they were able to provide
    a tutorial sepcifically tailored to my needs. It was amazing.

    TeamTutorials

    I recommend you hit them up and check them out if you need assistance.

    ReplyDelete
  3. Mr. Expert,

    Are you going to have a follow up post or article about this anytime soon? :)


    _______
    "Providing you with great tips on Lawyer reviews" ...
    ( http://www.QSLaw.com )

    ReplyDelete
  4. Hey,

    What happened to your follow up article?

    _______

    ReplyDelete
  5. Hi ... Any specific article you are looking for ?

    ReplyDelete
  6. Great beat ! I wish to apprentice while you amend your site, how can i subscribe for a blog website? The account helped me a acceptable deal. I have been a little bit familiar of this your broadcast offered shiny transparent idea

    ReplyDelete

Total Pageviews

Kanav's ReviewBookShelf

.




Comments

Contact Form

Name

Email *

Message *