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:
## Delete the specified file version using SharePoint 2010 web service in powershell $uri="http://serverName:10736/sites/ECT/_vti_bin/Versions.asmx?wsdl" ## $fileName is the string that contains the site-relative URL of the file [String]$fileName="Shared Documents/test.docx" ## $fileVersion is the string that contains the version that has to be deleted [String]$fileVersion="2"
## Web Service Reference - http://Site/_vti_bin/Versions.asmx $versionsWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential [System.Xml.XmlNode]$xmlNode=$versionsWebServiceReference.DeleteVersion($fileName,$fileVersion)
## Creates an Versions.xml file in the D:\ which contains all the versions for the specified file $output = New-Object -TypeName System.IO.StreamWriter -ArgumentList "D:\Versions.xml", $false $output.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>") $output.WriteLine($xmlNode.OuterXml) $output.WriteLine() $output.Dispose()
|
Versions.xml:
Specified file version 2.0 is deleted successfully.