The content type settings allow you to specify such settings as columns, display forms, workflows or document templates, but before adding content types on a library or list, it is helpful to understand the following:3
Content types can be configured to require that certain fields, also known as columns, contain information. When uploading or creating a document, if no information is included in the required columns, the user is prompted to provide it. The required columns are configured on and enforced by the content type, not by the list or library.
The fields that appear on a form are determined by the content type associated with that form, not by the list or library.
The document template that is used when creating a new document is specified by the content type, not the list or library.
Workflows and events can be bound to content types.
Content types that have a parent/child relationship with a higher level site can be affected by actions that occur when the parent content type is updated.
PowerShell ISE
In the ISE Window, add the paths to SharePoint Online SDK installed earlier. Verify if the paths are exactly the same, e.g. on Windows Server, you may need to change 15 into 16:
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Enter the credentials and the site where you want to change the content types management setting
$Username="trial@trialtrial123.onmicrosoft.com" $AdminPassword="Pass" $Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
$Username
=
"trial@trialtrial123.onmicrosoft.com"
$AdminPassword
"Pass"
$Url
"https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
$ContentTypesEnabled
$true
function
Set
-SPOListsContentTypesEnabled
{
}
param (
[Parameter(Mandatory=
,Position=1)]
[string]
,
,Position=2)]
,Position=3)]
,Position=4)]
[bool]
)
$password
= ConvertTo-SecureString -string
-AsPlainText -Force
=Read-Host -Prompt
"Enter password"
-AsSecureString
$ctx
=New-Object Microsoft.SharePoint.Client.ClientContext(
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(
$ctx.ExecuteQuery()
.ExecuteQuery()
$Lists
.Web.Lists
.Load(
Foreach(
$ll
in
.ContentTypesEnabled =
$ll.ContentTypesEnabled = $true
$ll.Update()
try { $ctx.ExecuteQuery() } catch [Net.WebException] { }
try
catch [Net.WebException]
Write-Host $ll.Title " Done" -ForegroundColor Green
Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red
Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=3)]
[string]$Url,
Set-SPOListsContentTypesEnabled -Username $Username -Url $Url
## Created by Someone Awesome, 2015#
function Set-SPOListsContentTypesEnabled
[Parameter(Mandatory=$true,Position=2)]
[string]$AdminPassword,
[Parameter(Mandatory=$true,Position=4)]
[bool]$ContentTypesEnabled
$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$Lists=$ctx.Web.Lists
$ctx.Load($Lists)
Foreach($ll in $Lists)
$ll.ContentTypesEnabled = $ContentTypesEnabled
# Paths to SDK. Please verify location on your computer.
# Insert the credentials and the name of the site and the desired setting: $true for the content types management to be allowed or $false to disable it
$Username="trial@trialtrial123.onmicrosoft.com"
$AdminPassword="Pass"
$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
$ContentTypesEnabled=$true
# Insert the credentials and the name of the site and list
$ListName="Tasks list"
$ContentTypesEnabled =$false
$password=Read-Host "Enter password" -AsSecureString
Again, param () defines the parameters that will be used later on in a function: param (
[string]$Url
Password. We can either take password from the input earlier
function Connect-SPOCSOM
$global:ctx=$ctx
function Set-SPOList
[Parameter(Mandatory=$true,Position=0)]
[string]$ListName,
$ll=$ctx.Web.Lists.GetByTitle($ListName)
Write-Host "Done" -ForegroundColor Green
$global:ctx
Connect-SPOCSOM -Username $Username -AdminPassword $AdminPassword -Url $Url
Set-SPOList -ListName $ListName -ContentTypesEnabled $ContentTypesEnabled
$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.Webs)
for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++)
Set-SPOListsContentTypesEnabled -Username $Username -Url $ctx.Web.Webs[$i].Url -AdminPassword $AdminPassword -ContentTypesEnabled $ContentTypesEnabled
} In order to notify about start of a new site, add a simple Write-Host line:
Write-Host "--"-ForegroundColor DarkGreen
It doesn't make sense to loop through the sites if there aren't any, so verify this condition in the beginning:
if($ctx.Web.Webs.Count -gt 0)
# Created by Arleta Wanat, 2015
#
The script is available also for download from the TechNet Script Gallery: