Basic PowerShell scripts

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.
  • Get-SPFarm
  • Get-SPWebApplication
  • Get-SPSite
  • $spsite = Get-SPSite “http://ServerName”

Or:

$spsite = Get-SPSite “http://ServerName”
$spsite | Get-SPWeb

$spsite.AllWebs | Select LastItemModifiedDate, Url, Created | Sort Created

Get-SPSite | Select URL, @{Name=”Storage”; Expression={“{0:N2} MB”
-f ($_.Usage.Storage/1000000)}}, @{Name=”Quota”;
Expression={“{0:N2} MB” -f ($_.Quota.StorageMaximumLevel/1000000)}
}