Thursday, October 20, 2011

SharePoint 2010 powershell commands

Introduction:
In this article we will discuss about PowerShell commands which is introduced in SharePoint 2010. You can also visit Powershell command to install activate feature SharePoint 2010.

Description:
In MOSS2007 there was stsadm command line tool to work with MOSS2007, but in SharePoint it comes with Windows PowerShell to work with SharePoint 2010. This commadline tool will be available after  SharePoint 2010 Products. The commands are know as cmdlets in powershell language.

To access power shell go to Start -> All Programs ->  Microsoft SharePoint 2010 Products
and the click on SharePoint 2010 Management Shell. You should have proper permission to use execute powershell cmdlets or commands.

Here I am providing some examples:
Get-SPFarm:
When you type this and press enter, it will give you the farm name and status wether it is online or offline.


Get-spwebapplication:
It will give you the displayname of list of web applications and there URL.
Get-spwebapplication -includecentraladministration:
This will give display name of list of web applications as well as the name of the central administartion and there corresponding URL.

Get-SPSite:
Returns all site collections.
Get-SPSite http://site-name/
This will give you all the sites from the given URL.

Add-SPSolution:
Add-SPSolution -LiteralPath [Path of WSP file]:
This will adds a SharePoint solution package to the farm.

Install-SPSolution:
Install-SPSolution -Identity [WSP file name] -GACDeployment:
This will deploys an installed SharePoint solution in the farm.

Add-SPUserSolution:
Add-SPUserSolution -LiteralPath [WSP file path] -Site http://yoursitename
The Add-SPUserSolution cmdlet uploads a new sandboxed solution package to the solution gallery.

Install-SPUserSolution:
Install-SPUserSolution -Identity [wspfilename] -Site http://yoursitename
The Install-SPUserSolution cmdlet activates a sandboxed solution in a site collection.

Install-SPFeature:
This cmdlet will Installs a SharePoint Feature by using the Feature.xml file.
Install-SPFeature -path "MyTestFeature"

Install-SPWebPartPack:
This will Install the specified Web Part package to the specified location
Install-SPWebPartPack "MyCustomWebPartPack" -LiteralPath "path of wpp" -GlobalInstall
GlobalInstall means it will install in GAC.

Install-SPWebTemplate:
This will install a site template.
Install-SPWebTemplate –path "template file path" –name "My Custom Template" –description "Test site template"

Get-SPServer:
It will return the list of servers.
Get-SPServer

Get-SPLogEvent:
Returns results from a Unified Logging Service (ULS) trace log
Get-SPLogEvent -MinimumLevel "Warning"

Get-SPDatabase:
It will give us all the properties of database.
Get-SPDatabase –ServerInstance "Bijay\SharePoint"

Backup-SPSite:
Perform a back up of a site collection.
Backup-SPSite [Site URL] -Path C:\Backup\siteback.bak
There are also lots of commands available in the MSDN URL.

No comments:

Post a Comment