Get all the SharePoint 2010 lists from the site using web service in Powershell

In this blog you will see how to get all the SharePoint lists from the 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:

  1. $uri="http://serverName:10736/sites/ECT/_vti_bin/Lists.asmx?wsdl"  
  2. $listWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential  
  3. [System.Xml.XmlNode]$xmlNode=$listWebServiceReference.GetListCollection()  
  4. ## Creates an Lists.xml file in the D:\ which contains all the Names and GUIDs   
  5. $output = New-Object -TypeName System.IO.StreamWriter -ArgumentList "D:\Lists.xml", $false  
  6. $output.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>")  
  7. $output.WriteLine($xmlNode.OuterXml)  
  8. $output.WriteLine()   
  9. $output.Dispose()  
  10. write-host -ForegroundColor Magenta "Getting all the lists title........."  
  11. foreach($node in $xmlNode.List)  
  12. {  
  13. ## Displays all the lists title from the site  
  14. write-host -ForegroundColor Green $node.Title  




Lists.xml:
  1. <?xml version="1.0" encoding="utf-8" ?>   
  2. -  <Lists xmlns="http://schemas.microsoft.com/sharepoint/soap/">  
  3.      <List DocTemplateUrl="" DefaultViewUrl="/sites/ECT/Lists/Announcements/AllItems.aspx" MobileDefaultViewUrl="" ID="{E598F298-91FC-4820-9BA8-1008A9B87A1D}" Title="Announcements" Description="Use this list to track upcoming events, status updates or other team news." ImageUrl="/_layouts/images/itann.png" Name="{E598F298-91FC-4820-9BA8-1008A9B87A1D}" BaseType="0" FeatureId="00bfea71-d1ce-42de-9c63-a44004ce0104" ServerTemplate="104" Created="20110719 03:46:40" Modified="20110719 03:46:41" LastDeleted="20110719 03:46:40" Version="0" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="536875008" ItemCount="1" AnonymousPermMask="0" RootFolder="" ReadSecurity="1" WriteSecurity="1" Author="1073741823" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailAlias="" WebFullUrl="/sites/ECT" WebId="c79ef89b-80ec-4703-8909-318dbf34a0b9" SendToLocation="" ScopeId="6186d5e1-b952-4506-af7e-04993ad9f0c4" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" NoThrottleListOperations="False" HasRelatedLists="" AllowDeletion="True" AllowMultiResponses="False" EnableAttachments="True" EnableModeration="False" EnableVersioning="False" HasExternalDataSource="False" Hidden="False" MultipleDataList="False" Ordered="False" ShowUser="True" EnablePeopleSelector="False" EnableResourceSelector="False" EnableMinorVersion="False" RequireCheckout="False" ThrottleListOperations="False" ExcludeFromOfflineClient="False" EnableFolderCreation="False" IrmEnabled="False" IsApplicationList="False" PreserveEmptyValues="False" StrictTypeCoercion="False" EnforceDataValidation="False" MaxItemsPerThrottledOperation="5000" />   
  4. .    .....  
  5. </Lists> 


Output:

Untitled.gif


For more information on please New-WebServiceProxy refer http://technet.microsoft.com/en-us/library/dd315258.aspx.