In this article, I am listing the mostly needed PowerShell scripts in SharePoint administration. Open the PowerShell command:
- On the Start menu, click All Programs.
- Click Microsoft SharePoint Products.
- Click SharePoint Management Shell.
Retrieve a Reference to the Farm
- Get-SPFarm
Retrieve a Collection of Web Applications in the Farm
- Get-SPWebApplication
List all SharePoint site collections
- Get-SPSite
- $spsite = Get-SPSite “http://ServerName”
Or:
$spsite = Get-SPSite “http://ServerName”
$spsite | Get-SPWeb
List specific properties of the webs
$spsite.AllWebs | Select LastItemModifiedDate, Url, Created | Sort Created
Display query result in grid view
Get-SPSite | Select URL, @{Name=”Storage”; Expression={“{0:N2} MB”
-f ($_.Usage.Storage/1000000)}}, @{Name=”Quota”;
Expression={“{0:N2} MB” -f ($_.Quota.StorageMaximumLevel/1000000)}
}