Get all items from picture library using SharePoint 2010 web service in powershell

I have a picture library named as "PL1" which contains a folder called "New Folder". Inside "New Folder" there is an item named Creek.jpg. In this you will see how to get the items from a particular folder in the picture library.

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:

 
##Get all items from picture library using SharePoint 2010 web service in powershell

$uri="http://serverName:10736/sites/ECT2/_vti_bin/Imaging.asmx?wsdl"
## $listName is a string that contains the picture library name from which you need to get all the items
$listName="PL1"
## $strParentFolder is a string that contains the parent folder relative path from where you need to get the items
$strParentFolder="New Folder"

## Web Service Reference - http://Site/_vti_bin/Imaging.asmx
$imagingWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential
[
System.Xml.XmlNode]$xmlNode=$imagingWebServiceReference.GetListItems($listName,$strParentFolder)

## Creates an GetPicLibItems.xml file in the D:\ which contains all the items from the specified picture library and folder
$output = New-Object -TypeName System.IO.StreamWriter -ArgumentList "D:\GetPicLibItems.xml", $false
$output.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>")
$output.WriteLine($xmlNode.OuterXml)
$output.WriteLine()
$output.Dispose()


Output:

output.jpg