Get the SharePoint 2010 site using web service in powershell

Steps Involved:

  1. Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run as Administrator).
  2. Run the following script.

Powershell Script:

 
## Input Parameters required to get the SharePoint 2010 site using web service
## Web Service Reference - http://Site/_vti_bin/Sites.asmx
$uri="http://serverName:10736/sites/ECT/_vti_bin/Sites.asmx?wsdl"
$SiteUrl="http://serverName:10736/sites/ECT"

$sitesWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential
$site=$sitesWebServiceReference.GetSite($SiteUrl)
## Returns the string value
## <Site Url="http://serverName:10736/sites/ECT" Id="{183116c5-b483-4376-965d-efd8e6c5c02f}" UserCodeEnabled="True" />
write-host -ForegroundColor Green $site