Office 365 SharePoint Online Create Folder Using PowerShell

This blog will create a folder in document library in SharePoint Online using Powershell Cmdlts.
Creating folder in a SharePoint document library gives you an efficient way to group and manage your content, such as grouping reports by fiscal year or department.
 
Create Folder in SharePoint 2013 Online UI method.
  • Navigate to the SharePoint site containing the SharePoint library where you want to add the folder.
  • Click the name of the library on the Quick Launch bar, or click Settings , and click Site contents, and then click the title of the library you want to add folders to.
Steps
  • 1.Open SharePoint Management Shell.
  • 2.Copy the below Code and paste it.
  • 3.Run the Code.
  1. ##########################    
  2.   
  3. #Script: Below Script will create a new Folder in Office 365 SharePoint Online   
  4. #Author: Gowtham Rajamanickam    
  5. #Date  :16-03-2017    
  6.   
  7. #########################  
  8.  
  9. #Before Run the Scritp you must load the Client Assembly files   
  10.    
  11. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"  
  12. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"  
  13.      
  14.   
  15. function createFolder{  
  16.      
  17. param ($SiteUrl, $ListURL, $FolderName, $UserName ,$Password)     
  18.    
  19. #Connect Office 365 SharePoint Online Site  
  20. $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))    
  21.   
  22. $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)  
  23. $Context.Credentials = $credentials  
  24.     
  25. #Get the List Root Folder  
  26. $ParentFolder=$Context.web.GetFolderByServerRelativeUrl($ListName)  
  27.   
  28. #Create New Folder  
  29. $Folder = $ParentFolder.Folders.Add($FolderName)  
  30. $ParentFolder.Context.Load($Folder)  
  31. $ParentFolder.Context.ExecuteQuery()  
  32.    
  33. Write-host "New Folder Created Successfully!"  
  34. }  
  35.   
  36. createFolder "https://gowthamr.sharepoint.com/" "Documents" "TutorialFolder" "[email protected]" "Enter your Password here"  
Was my Blog helpful? Was it missing content? If so, please let us know what's confusing or missing at the bottom of this page.

Thanks for reading my blogs.