How to execute commands in SharePoint 2010 PowerShell?


Write PowerShell code in notepad -> save notepad file with .ps1 extension, i.e. ‘getSiteName.ps1 -> Save it in c:\ -> execute this file using following command with file name:
c:\ .\getSiteName.ps1

Your command will get executed and result will be displayed.


Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

$spSite = Get-SPSite -Identity "http:/abcd/"
foreach ($spWeb in $spSite.AllWebs)

It will display the name of site and title.

Ebook Download
View all
View all