Requirement: Create a document library in SharePoint online using PowerShell
SharePoint online: PowerShell to Create Document Library:
How to Create document library in SharePoint online using PowerShell?
Related post: How to create a list in sharepoint online using PowerShell
SharePoint online: PowerShell to Create Document Library:
How to Create document library in SharePoint online using PowerShell?
#Load SharePoint CSOM Assembliesand the result:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null
#Variables for Processing
$SiteURL = "https://Crescent.sharepoint.com/Sites/Sales"
$LoginName ="Salaudeen@Crescent.OnMicrosoft.com"
$LoginPassword ="Password"
#Get the Client Context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
#supply Login Credentials
$SecurePWD = ConvertTo-SecureString $LoginPassword –asplaintext –force
$Credential = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($LoginName,$SecurePWD)
$Context.Credentials = $Credential
#Create new document library
$ListInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$ListInfo.Title = "Project Docs"
$ListInfo.TemplateType = 101 #Document Library
$List = $Context.Web.Lists.Add($ListInfo)
$List.Description = "Repository to store project artifacts"
$List.Update()
$Context.ExecuteQuery()
write-host "New Document Library has been created!"
Related post: How to create a list in sharepoint online using PowerShell