Use the below csom powershell to create a document library in SharePoint online
for that you need only 2 dlls for reference
Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
copy the below powershell code in a file and save it as .ps1 and make sure the above dlls placed where this ps1 file exists for the reference. other wise you can hard code the file location in the given script
$host.Runspace.ThreadOptions = "ReuseThread"
function Create-NewListSPO
{
param ($sCSOMPath,$sSiteUrl,$sUserName,$sPassword,$sListName,$sListDescription)
try
{
#Adding the Client OM Assemblies
$sCSOMRuntimePath=$sCSOMPath + "\Microsoft.SharePoint.Client.Runtime.dll"
$sCSOMPath=$sCSOMPath + "\Microsoft.SharePoint.Client.dll"
Add-Type -Path $sCSOMPath
Add-Type -Path $sCSOMRuntimePath
#SPO Client Object Model Context
$spoCtx = New-Object Microsoft.SharePoint.Client.ClientContext($sSiteUrl)
$spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($sUserName, $sPassword)
$spoCtx.Credentials = $spoCredentials
Write-Host "----------------------------------------------------------------------------" -foregroundcolor Green
Write-Host "Creating Library $sListName in $sSiteUrl !!" -ForegroundColor Green
Write-Host "----------------------------------------------------------------------------" -foregroundcolor Green
$spoWeb=$spoCtx.Web
$spoListCreationInformation=New-Object Microsoft.SharePoint.Client.ListCreationInformation
$spoListCreationInformation.Title=$sListName
#https://msdn.microsoft.com/EN-US/library/office/microsoft.sharepoint.client.listtemplatetype.aspx
$spoListCreationInformation.TemplateType=[int][Microsoft.SharePoint.Client.ListTemplatetype]::DocumentLibrary
$spoList=$spoWeb.Lists.Add($spoListCreationInformation)
$spoList.Description=$sListDescription
$spoCtx.ExecuteQuery()
Write-Host "----------------------------------------------------------------------------" -foregroundcolor Green
Write-Host "Library $sListName created in $sSiteUrl !!" -ForegroundColor Green
Write-Host "----------------------------------------------------------------------------" -foregroundcolor Green
Read-Host -Prompt "Press any key to close this"
$spoCtx.Dispose()
}
catch [System.Exception]
{
Write-Host -ForegroundColor Red $_.Exception.ToString()
}
}
$sSiteUrl = "https://domain.sharepoint.com/sites/dev" # any site/sub site url
$sUserName = "[email protected]" # online user
$sListName= Read-Host -Prompt "Enter List Name "
$sListDescription="Using Powershell I am created"
$sPassword = Read-Host -Prompt "Enter your password " -AsSecureString
#$sPassword=ConvertTo-SecureString "<SPO_Password>" -AsPlainText -Force
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
Create-NewListSPO -sCSOMPath $dir -sSiteUrl $sSiteUrl -sUserName $sUserName -sPassword $sPassword -sListName $sListName -sListDescription $sListDescription
Use the below link to create different type of lists GenericList,DocumentLibrary,Surveys..etc
https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listtemplatetype.ASPX