$lci
=New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
Content type IDs uniquely identify the content type and are designed to be recursive. The content type ID encapsulates that content type's lineage, or the line of parent content types from which the content type inherits. Each content type ID contains the ID of the parent content type, which in turn contains the ID of that content type's parent, and so on, ultimately back to and including the System content type ID. SharePoint Foundation uses this information to determine the relationship between content types and for push-down operations.[1]
You can construct a valid content type ID using one of two conventions:
[System.Guid]::NewGuid().toString()or [guid]::NewGuid()
[System.Guid]::NewGuid().toString()
[guid]::NewGuid()
$lci.ID=
"0x0108009e862727eed04408b2599b25356e7914"
$lci.ParentContentType=$ctx.Web.ContentTypes.GetById(
"0x01"
)
Add-Type -Path
"c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
"c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$ctx
=New-Object Microsoft.SharePoint.Client.ClientContext(
$Url
.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(
$Username
,
$AdminPassword
.ExecuteQuery()
.Description=
"Description"
.Name=
"Powershell Content Type2"
.ParentContentType=
.Web.ContentTypes.GetById(
.Group=
"List Content Types"
=
New
-
Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
#$lci.Description="Description"
$lci.Name
"Powershell Content Type2id22aa"
#$lci.Group="List Content Types"
$lci.ID
"0x0100aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
$ContentType
.Web.ContentTypes.Add(
.Load(
$contentType
try
{
Write-Host
"Content Type "
$Title
" has been added to "
}
catch [Net.WebException]
$_
.Exception.ToString()
function
New-SPOContentType
param(
[Parameter(Mandatory=
$true
,Position=1)]
[string]
,Position=2)]
,Position=3)]
# Paths to SDK. Please verify location on your computer.
# Insert the credentials
and
the name of the admin site
"admin@tenant.onmicrosoft.com"
=Read-Host -Prompt
"Password"
-AsSecureString
$AdminUrl
"https://tenant.sharepoint.com/sites/teamsitewithlibraries"
New-SPOContentType -Username
-AdminPassword
-Url
Select the Options button and then select Site Settings.
Under Site Collection Administration, click Content type publishing.
In the Hubs section, you can see the names of any Managed Metadata Service applications that publish content types to this site collection listed in bold text. After the service application names, you can see the URLs for the hub sites. You can also see a list of the subscribed content types.
,Position=4)]
$Description
,Position=5)]
$Name
,Position=6)]
$Group
,Position=7)]
$ParentContentTypeID
#
.ID=
"https://tenant.sharepoint.com/sites/contenttypehub"
"desc"
"From Powershell directly to CTH"
-Description
-Name
-Group
-ParentContentTypeID
.Web.Lists.GetByID(
"4C834F99-D908-4E1C-A04F-C8B1F971371C"
.Web.Lists.GetByTitle(
"The Title of My List"
.Web.Lists)
foreach
(
$ll
in
#Add Content Type here
tasks lists
if
.BaseTemplate -eq 107 -
or
.BaseTemplate -eq 171)
# Add Content Type comes here
lists with workflows
.WorkflowAssociations)
.WorkflowAssociations.
Count
-gt 0)
"0x0100aa862727aed04408b2599b25356e7000"
.ContentTypes.Add(
"Adding content type "
" to "
.Title
"https://tenant.sharepoint.com/sites/teamsitewithlists"
"From PS to Tasks234"
"0x0107"
$ContentTypeID
$ListTitle
.load(
.ContentTypes)
.ContentTypesEnabled=
$AddedContentType
.ContentTypes.AddExistingContentType(
.Update()
.Name
Add-SPOContentType
"tas1207"
"0x01200200C44754774BD8D4449F4B7E3FE70A7E0E"
Add-SPOContentType -Username
-ListTitle
-ContentTypeID
Get all properties of all content types in a SharePoint site Get All Properties of All Content Types (Detailed) Get All Properties of All Content Types in All Lists (Detailed) across one site
Get properties of a single content type by its ID Get content types belonging to a group Get All Hidden Content Types added to the site Get Single Content Type - Array Method Get Names of all content types added to your SPO lists Get Names of All Content Types Get Names of all Available Content Types Get Content Types Derived From One Parent Get content types which cannot be modified Get Content Types with a particular column Find Custom Display Forms Deployed on your lists using Powershell Verify the content types used in your lists against the default ones Retrieve all Content Types from a Content Type Hub and their DisplayFormTemplate