Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

SharePoint Online: Create a Document Library or List with New Experience UI using PowerShell-CSOM

$
0
0
The new list and library experience in SharePoint Online improves the user experience by providing many features such as navigation, fast response, mobile UI, easier to use, etc. You can switch between classic & new experiences anytime. Here is the PowerShell-CSOM script to create a document library in SharePoint online with new experience UI.

PowerShell Script to create a document library in new experience UI:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

##Variables for Processing
$SiteUrl = "https://crescent.sharepoint.com/Projects"
$UserName="salaudeen@crescent.com"
$Password ="Password goes here"

#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))

Try {
#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $credentials

#Create new document library
$ListInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$ListInfo.Title = "Project Documents"
$ListInfo.TemplateType = 101 #Document Library
$List = $Context.Web.Lists.Add($ListInfo)

#Set "New Experience" as list property
$List.ListExperienceOptions = "NewExperience" #Or ClassicExperience
$List.Update()
$Context.ExecuteQuery()

Write-host "New Document Library Created!" -ForegroundColor Green
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

This creates a new library "Project Documents" in modern new experience UI.
sharepoint online new list experience

Viewing all articles
Browse latest Browse all 1058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>