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
@@ -1,54 +1,46 @@
function New-SPOContentType
{
param(
[Parameter(Mandatory=$true,Position=1)]
function New-SPOContentType{
param(
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
$AdminPassword,
[Parameter(Mandatory=$true,Position=3)]
[Parameter(Mandatory=$true,Position=3)]
[string]$Url,
[Parameter(Mandatory=$true,Position=4)]
[Parameter(Mandatory=$true,Position=4)]
[string]$Description,
[Parameter(Mandatory=$true,Position=5)]
[Parameter(Mandatory=$true,Position=5)]
[string]$Name,
[Parameter(Mandatory=$true,Position=6)]
[Parameter(Mandatory=$true,Position=6)]
[string]$Group,
[Parameter(Mandatory=$true,Position=7)]
[Parameter(Mandatory=$true,Position=7)]
[string]$ParentContentTypeID

)

$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
$ctx.Load($ctx.Web.Lists)
$ctx.ExecuteQuery()



$lci =New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
$lci.Description=$Description
$lci.Name=$Name
#$lci.ID="0x0108009e862727eed04408b2599b25356e7914"
$lci.ParentContentType=$ctx.Web.ContentTypes.GetById($ParentContentTypeID)
$lci.Group=$Group

foreach($ll in $ctx.Web.Lists)
{
$ContentType = $ll.ContentTypes.Add($lci)
$ctx.Load($contentType)
try
{

$ctx.ExecuteQuery()
Write-Host "Content Type " $Name " has been added to " $ll.Title
}
catch [Net.WebException]
{
Write-Host $_.Exception.ToString()
}


}
)

$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
$ctx.Load($ctx.Web.Lists)
$ctx.ExecuteQuery()


$lci =New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
$lci.Description=$Description
$lci.Name=$Name
#$lci.ID="0x0108009e862727eed04408b2599b25356e7914"
$lci.ParentContentType=$ctx.Web.ContentTypes.GetById($ParentContentTypeID)
$lci.Group=$Group

foreach($ll in $ctx.Web.Lists){
$ContentType = $ll.ContentTypes.Add($lci)
$ctx.Load($contentType)

try{
$ctx.ExecuteQuery()
Write-Host "Content Type " $Name " has been added to " $ll.Title
}
catch [Net.WebException]{
Write-Host $_.Exception.ToString()
}
}
}


Expand All @@ -68,4 +60,4 @@ $Group="List Content Types"



New-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -Description $Description -Name $Name -Group $Group -ParentContentTypeID $ParentContentTypeID
New-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -Description $Description -Name $Name -Group $Group -ParentContentTypeID $ParentContentTypeID