Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions Content Types/Create/Create a content type/CreateContentType.ps1
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
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
)

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


$lci =New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
$lci.Description="Description"
$lci.Name="Powershell Content Type222Task Based"
#$lci.ID="0x0108009e862727eed04408b2599b25356e7914"
$lci.ParentContentType=$ctx.Web.ContentTypes.GetById("0x01")
$lci.Group="List Content Types"

$ContentType = $ctx.Web.ContentTypes.Add($lci)
$ctx.Load($contentType)
try
{

$ctx.ExecuteQuery()
Write-Host "Content Type " $Title " has been added to " $Url
}
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.ExecuteQuery()


$lci =New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
$lci.Description="Description"
$lci.Name="Powershell Content Type222Task Based"
#$lci.ID="0x0108009e862727eed04408b2599b25356e7914"
$lci.ParentContentType=$ctx.Web.ContentTypes.GetById("0x01")
$lci.Group="List Content Types"

$ContentType = $ctx.Web.ContentTypes.Add($lci)
$ctx.Load($contentType)

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


Expand Down