Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,42 @@
# Created by Arleta Wanat, 2015
#

function Set-SPOListsContentTypesEnabled
{
param (
[Parameter(Mandatory=$true,Position=1)]
function Set-SPOListsContentTypesEnabled{
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
[string]$AdminPassword,
[Parameter(Mandatory=$true,Position=3)]
[Parameter(Mandatory=$true,Position=3)]
[string]$Url,
[Parameter(Mandatory=$true,Position=4)]
[Parameter(Mandatory=$true,Position=4)]
[bool]$ContentTypesEnabled
)
)

$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force

$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
$ctx.ExecuteQuery()

$Lists=$ctx.Web.Lists
$ctx.Load($Lists)
$ctx.ExecuteQuery()
$Lists=$ctx.Web.Lists

$ctx.Load($Lists)
$ctx.ExecuteQuery()

Foreach($ll in $Lists)
{
$ll.ContentTypesEnabled = $ContentTypesEnabled
$ll.Update()

Foreach($ll in $Lists){
$ll.ContentTypesEnabled = $ContentTypesEnabled
$ll.Update()

try
{
$ctx.ExecuteQuery()
Write-Host $ll.Title " Done" -ForegroundColor Green
}
try{
$ctx.ExecuteQuery()
Write-Host $ll.Title " Done" -ForegroundColor Green
}
catch [Net.WebException]{
Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red
}

catch [Net.WebException]
{

Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red
}

}
}
}


Expand All @@ -68,4 +63,4 @@ $ContentTypesEnabled=$true



Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled
Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled