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. ## Get all the views for the specified SharePoint 2010 list using web service in powershell
  2. ## Web Service Reference - http://Site/_vti_bin/Views.asmx
  3. $uri="http://serverName:10736/sites/ECT/_vti_bin/Views.asmx?wsdl"
  4. ## $listName is the string that contains the list name from which we need to get all the views
  5. [String]$listName="List"
  6. $viewsWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential
  7. ## GetViewCollection method is used to return the collection of views for the specified SharePoint 2010 list
  8. [System.Xml.XmlNode]$xmlNode=$viewsWebServiceReference.GetViewCollection($listName)
  9. ## Creates an ViewCollection.xml file in the D:\ which contains all the views for the specified SharePoint 2010 list
  10. $output = New-Object -TypeName System.IO.StreamWriter -ArgumentList "D:\ViewCollection.xml", $false
  11. $output.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>")
  12. $output.WriteLine($xmlNode.OuterXml)
  13. $output.WriteLine()
  14. $output.Dispose()
  15. Write-Host -ForegroundColor Magenta "Displaying all the view Names............"
  16. foreach($view in $xmlNode.View)
  17. {
  18. Write-Host -ForegroundColor Green $view.DisplayName
  19. }



Output:

ViewColl.jpg


ViewCollection.xml:

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. - <Views xmlns="http://schemas.microsoft.com/sharepoint/soap/">
  3. <View Name="{D959C5C0-93AF-443B-8446-5011883094E3}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Items" Url="/sites/ECT/Lists/List/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png" />
  4. </Views>