SharePoint Online: Get List Content Types using PowerShell

Requirement: Get All List Content Types in SharePoint Online

SharePoint Online List Content Types
To get all content types of a  SharePoint List or library, go to List Settings, and you'll find all content types of the list
SharePoint Online Get List Content Types using PowerShell

SharePoint Online: PowerShell to Get List Content Types
#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"
 
#Set parameter values
$SiteURL="https://crescenttech.sharepoint.com/"
$ListName="Projects"

#Get Credentials to connect
$Cred= Get-Credential
  
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
 
#Get the List
$List = $Ctx.Web.lists.GetByTitle($ListName)

#Get All content types of the list
$ContentTypes = $List.ContentTypes
$Ctx.Load($ContentTypes)
$Ctx.ExecuteQuery()

#Get Content Type Details
$ContentTypes | Select Name,Description, Group, ID
and the output:
sharepoint online powershell get list content types

To get content types of all lists in SharePoint Online, use: SharePoint Online: Get Content Type usage using PowerShell
SharePoint Online: Get List Content Types using PowerShell SharePoint Online: Get List Content Types using PowerShell Reviewed by Salaudeen Rajack on February 27, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.