Create new folder in picture library using SharePoint 2010 web service in powershell



In this you will see how to create a new folder with the name "New folder" in the specified picture library and folder.

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:

 
 
##Create new folder in 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 in which new folder has to be created
$listName="PL1"
## $strParentFolder is a string that contains the parent folder relative path inside which you need to create the new folder
## For example if you want to create a folder inside the folder specify the relative path from the root of the list to the parent folder.
$strParentFolder=""

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

Output:

output.jpg



If a folder named "New folder" already exists in the specified folder, the CreateNewFolder method tries to create "New folder(1)", "New folder(2)", and so on.



Ebook Download
View all
Learn
View all