Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,45 @@
# Created by Arleta Wanat, 2015
#

function Set-SPOList
{
param (
[Parameter(Mandatory=$true,Position=0)]
function Set-SPOList{
param(
[Parameter(Mandatory=$true,Position=0)]
[string]$ListName,
[Parameter(Mandatory=$true,Position=1)]
[Parameter(Mandatory=$true,Position=1)]
[bool]$ContentTypesEnabled
)
)

$ll=$ctx.Web.Lists.GetByTitle($ListName)
$ll=$ctx.Web.Lists.GetByTitle($ListName)

$ll.ContentTypesEnabled = $ContentTypesEnabled
$ll.Update()

try
{
$ctx.ExecuteQuery()
Write-Host "Done" -ForegroundColor Green
}

catch [Net.WebException]
{

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

$ll.ContentTypesEnabled = $ContentTypesEnabled
$ll.Update()

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




function Connect-SPOCSOM
{
param (
[Parameter(Mandatory=$true,Position=1)]
function Connect-SPOCSOM{
param(
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
[string]$AdminPassword,
[Parameter(Mandatory=$true,Position=2)]
[Parameter(Mandatory=$true,Position=2)]
[string]$Url
)
)


$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()
$global:ctx=$ctx
$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()
$global:ctx=$ctx
}


$global:ctx


Expand All @@ -77,4 +64,4 @@ $ContentTypesEnabled =$false

Connect-SPOCSOM -Username $Username -AdminPassword $AdminPassword -Url $Url

Set-SPOList -ListName $ListName -ContentTypesEnabled $ContentTypesEnabled
Set-SPOList -ListName $ListName -ContentTypesEnabled $ContentTypesEnabled