Steps Involved:
- Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run as Administrator).
- Run the following script.
Powershell Script:
## Input Parameters required for getting the URLs for the attachments $uri="http://serverName:10736/sites/ECT/_vti_bin/Lists.asmx?wsdl" [string] $listItemId="2" [string] $listName="List"
$listWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential [System.Xml.XmlNode]$xmlNode=$listWebServiceReference.GetAttachmentCollection($listName,$listItemId) ## Creates an Attachments.xml file in the D:\ which contains the URLS for the attachements $output = New-Object -TypeName System.IO.StreamWriter -ArgumentList "D:\Attachments.xml", $false $output.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>") $output.WriteLine($xmlNode.OuterXml) $output.WriteLine() $output.Dispose() write-host -ForegroundColor Magenta "Getting all the attachment URLs for the specified SharePoint list item........." foreach($node in $xmlNode.Attachment) { ## Displays all the attachment URLs for the specified list item write-host -ForegroundColor Green $node }
|
Attachments.xml:
<?xml version="1.0" encoding="utf-8" ?> - <Attachments xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <Attachment>http://serverName:10736/sites/ECT/Lists/List/Attachments/2/Lists.xml</Attachment> </Attachments>
|