Monday, 19 January 2015

How to use Windows PowerShell in SharePoint 2010

Using PowerShell in SharePoint 2010 :

Run following command to add Microsoft.Sharepoint.PowerShell Snap In (If not added before)
Add-PSSnapin Microsoft.Sharepoint.PowerShell

To declare a variable use  $variable name
Assign value to variable
$site=Get-SPSite  sitecollectionurl
$site is a variable name which is holding site collection object
To get all the members(mehod and properties)  type
$site| Get-Member
Above command displays all the members of $site object
To Export Data into CSV File
Create one array by typing
 $CSVContent=@()                          //Creates an array of name CSVContent
Add data into the created array(ie. CSVContent) by typing
$CSVContent+=$site | Get-Member                      //Add the members into Array

$CSVContent | Export-CSV  “AnyFileName.csv”-NoTypeInformation      // Exports the CSV file which contains all the member information of site collection object