Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ff1ab75
Update description.md
JakubPiegza Jan 30, 2020
be621d1
Update AddExistingContentTypetoOneList.ps1
JakubPiegza Jan 30, 2020
5a62636
Update ModifyDisplayFormTemplateName-ContentTypeHub.ps1
JakubPiegza Jan 30, 2020
cd521ba
Update CompareAvVSCT.ps1
JakubPiegza Jan 30, 2020
93c0f4a
Update GetSingleContentTypeLoop.ps1
JakubPiegza Jan 30, 2020
43e208d
Update description.md
JakubPiegza Feb 27, 2020
7e57412
Update BulkUpdate.ps1
JakubPiegza Feb 27, 2020
1f79781
Update description.md
JakubPiegza Feb 27, 2020
0e7c4f5
Update NewSPOListItem.psm1
JakubPiegza Feb 27, 2020
6376a30
Update description.md
JakubPiegza Feb 27, 2020
28b6142
Update GetSPOListItemCount.psm1
JakubPiegza Feb 27, 2020
25f3980
Update description.md
JakubPiegza Feb 27, 2020
774d914
Update GetSPOListItems9.psm1
JakubPiegza Feb 27, 2020
fc1941a
Update description.md
JakubPiegza Feb 27, 2020
31b7b08
Update description.md
JakubPiegza Feb 27, 2020
d81d256
Update SPOListItemFunctions.psm1
JakubPiegza Feb 27, 2020
638d1a4
Update description.md
JakubPiegza Feb 27, 2020
aee4b14
Update RemovePermissionsFromItems.ps1
JakubPiegza Feb 27, 2020
06463f1
Merge pull request #151 from PowershellScripts/master
PowershellScripts Mar 6, 2020
9fad483
Create description.md
PowershellScripts Mar 6, 2020
7189d90
Add files via upload
PowershellScripts Mar 6, 2020
ea12685
Create description.md
PowershellScripts Mar 7, 2020
9d63c43
Add files via upload
PowershellScripts Mar 7, 2020
8e6e3ae
Create description.md
PowershellScripts Mar 7, 2020
822675c
Add files via upload
PowershellScripts Mar 7, 2020
27ba5a0
Update and rename tenantProps (1).ps1 to tenantProps.ps1
PowershellScripts Mar 7, 2020
8b791b9
Create description.md
PowershellScripts Mar 7, 2020
78674cc
Create readme.md
PowershellScripts Mar 7, 2020
dc5b302
Create tobedeleted.txt
PowershellScripts Mar 7, 2020
5adf02a
Add files via upload
PowershellScripts Mar 7, 2020
bfdc76b
Add files via upload
PowershellScripts Mar 7, 2020
95139ad
Create description.md
PowershellScripts Mar 7, 2020
166ed59
Add files via upload
PowershellScripts Mar 7, 2020
4cea6e0
added ODB copies
PowershellScripts Mar 7, 2020
a23571d
Merge branch 'develop' of https://github.com/PowershellScripts/AllGal…
PowershellScripts Mar 7, 2020
acec70c
chnaged to spserver
PowershellScripts Mar 7, 2020
bc0a423
Merge branch 'structure-fixes' of https://github.com/PowershellScript…
PowershellScripts Mar 7, 2020
5234c38
Merge pull request #152 from PowershellScripts/structure-fixes
PowershellScripts Mar 7, 2020
ac5ea9c
Create description.md
PowershellScripts Mar 7, 2020
23db1c8
Add files via upload
PowershellScripts Mar 7, 2020
d44d527
Merge pull request #136 from JakubPiegza/format-Items-Management
PowershellScripts Mar 8, 2020
ce7604d
Merge pull request #67 from JakubPiegza/patch-14
PowershellScripts Mar 8, 2020
d4e695c
Merge pull request #68 from JakubPiegza/patch-15
PowershellScripts Mar 8, 2020
a403bb1
Merge pull request #84 from JakubPiegza/patch-31
PowershellScripts Mar 8, 2020
d23c20d
Merge pull request #86 from JakubPiegza/patch-33
PowershellScripts Mar 8, 2020
da8da04
Merge pull request #94 from JakubPiegza/patch-41
PowershellScripts Mar 8, 2020
d603a37
sample results
PowershellScripts Mar 8, 2020
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,47 +1,40 @@
function Add-SPOContentType
{
param(
[Parameter(Mandatory=$true,Position=1)]
function Add-SPOContentType{
param(
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
[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]$ListTitle,
[Parameter(Mandatory=$true,Position=7)]
[Parameter(Mandatory=$true,Position=7)]
[string]$ContentTypeID
)

$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()

$contentType=$ctx.Web.ContentTypes.GetById($ContentTypeID)
$ctx.Load($contentType)

$ll=$ctx.Web.Lists.GetByTitle($ListTitle)
$ctx.load($ll)
$ctx.load($ll.ContentTypes)
$ctx.ExecuteQuery()
$ll.ContentTypesEnabled=$true
$AddedContentType=$ll.ContentTypes.AddExistingContentType($contentType)
$ll.Update()

try
{

$ctx.ExecuteQuery()
Write-Host "Adding content type " $AddedContentType.Name " 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()

$contentType=$ctx.Web.ContentTypes.GetById($ContentTypeID)
$ctx.Load($contentType)

$ll=$ctx.Web.Lists.GetByTitle($ListTitle)
$ctx.load($ll)
$ctx.load($ll.ContentTypes)
$ctx.ExecuteQuery()
$ll.ContentTypesEnabled=$true
$AddedContentType=$ll.ContentTypes.AddExistingContentType($contentType)
$ll.Update()

try{
$ctx.ExecuteQuery()
Write-Host "Adding content type " $AddedContentType.Name " to " $ll.Title
}
catch [Net.WebException]{
Write-Host $_.Exception.ToString()
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ A short script to add an existing site content type directly to a SharePoint Onl



The script is fully described in an article here:

http://social.technet.microsoft.com/wiki/contents/articles/31051.sharepoint-online-content-types-in-powershell.aspx
The script is fully described in an article [here](http://social.technet.microsoft.com/wiki/contents/articles/31051.sharepoint-online-content-types-in-powershell.aspx).


### How to use?

1. Download and install SharePoint Online SDK.
1. Download and install [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038).

2. Download the .ps1 file.
2. Download the *.ps1* file.

3. Open the file (you can do it also in NotePad)

Expand All @@ -35,21 +33,23 @@ $ContentTypeID="0x01200200C44754774BD8D4449F4B7E3FE70A7E0E"
</br>d) Enter the title of the list.
</br>e) Enter the content type id
</br>
###### How to find the content type id?
* via browser
Go to Site>Gear Icon>Site Settings>Content Types>Click on the content type. The url at this point should look like this:
https://tenant.sharepoint.com/sites/TeamsitewithLists/_layouts/15/ManageContentType.aspx?ctype=0x0100A02B0ABDDEDC5A45AC64F100F30899CF&Source=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fsites%2FTeamsitewithLists%2F%5Flayouts%2F15%2Fmngctype%2Easpx
##### *How to find the content type id?*
* via browser </br>
Go to **Site**>**Gear Icon**>**Site Settings**>**Content Types**>**Click on the content type**. The url at this point should look like **[this](https://tenant.sharepoint.com/sites/TeamsitewithLists/_layouts/15/ManageContentType.aspx?ctype=0x0100A02B0ABDDEDC5A45AC64F100F30899CF&Source=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fsites%2FTeamsitewithLists%2F%5Flayouts%2F15%2Fmngctype%2Easpx)**.
```diff
https://tenant.sharepoint.com/sites/TeamsitewithLists/_layouts/15/ManageContentType.aspx?ctype=
- 0x0100A02B0ABDDEDC5A45AC64F100F30899CF
&Source=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fsites%2FTeamsitewithLists%2F%5Flayouts%2F15%2Fmngctype%2Easpx
```
Marked in red is the content type id.

* via another script
Get all properties of all content types in a SharePoint site

* via another script </br>
[Get all properties of all content types in a SharePoint site](https://gallery.technet.microsoft.com/Get-all-properties-of-all-3a9c5c4b)

5. Run the script in Powershell (any module).

6. When the script has executed, Powershell will show a message Content Type Name of the Content Type2 has been added to Url of the Site.
6. When the script has executed, Powershell will show a message *Content Type Name of the Content Type2 has been added to Url of the Site*.



<br/><br/>
<b>Enjoy and please share feedback!</b>
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@


function Set-SPOContentType
{

param (
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
$AdminPassword,
[Parameter(Mandatory=$true,Position=3)]
[string]$Url
)
function Set-SPOContentType{
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
$AdminPassword,
[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.Load($ctx.Web.ContentTypes)
$ctx.ExecuteQuery()


foreach($cc in $ctx.Web.ContentTypes)
{

Write-Host $cc.Name " " $cc.DisplayFormTemplateName



foreach($cc in $ctx.Web.ContentTypes){
Write-Host $cc.Name " " $cc.DisplayFormTemplateName
}



$ctx.Dispose()


}
$ctx.Dispose()
}



Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,44 @@


function Get-SPOContentType
{

param (
[Parameter(Mandatory=$true,Position=1)]
function Get-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()

$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.AvailableContentTypes)
$ctx.ExecuteQuery()
Write-Host
# Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen
$i=0
foreach( $cc in $ctx.Web.AvailableContentTypes)
{

$i++

}
Write-Host "Available content types " $i

$ctx.Load($ctx.Web.ContentTypes)
$ctx.ExecuteQuery()
Write-Host
# Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen
$i=0
foreach( $cc in $ctx.Web.ContentTypes)
{

$i++

}
Write-Host "Content types in this site " $i



}













)

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

$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.AvailableContentTypes)
$ctx.ExecuteQuery()
Write-Host
# Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen
$i=0

foreach( $cc in $ctx.Web.AvailableContentTypes){
$i++
}

Write-Host "Available content types " $i

$ctx.Load($ctx.Web.ContentTypes)
$ctx.ExecuteQuery()
Write-Host
# Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen
$i=0

foreach( $cc in $ctx.Web.ContentTypes){
$i++
}

Write-Host "Content types in this site " $i
}



Expand All @@ -73,4 +53,4 @@ $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries/subsite"



Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl
Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl
Original file line number Diff line number Diff line change
@@ -1,48 +1,32 @@


function Get-SPOContentType
{

param (
[Parameter(Mandatory=$true,Position=1)]
function Get-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()

$ctx.Load($ctx.Web)

$ctx.Load($ctx.Web.ContentTypes)
$ctx.ExecuteQuery()


foreach($cc in $ctx.Web.ContentTypes)
{
if($cc.Hidden -eq $true)
{
Write-Host $cc.Name
}
}
)







}

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




$ctx.Load($ctx.Web)

$ctx.Load($ctx.Web.ContentTypes)
$ctx.ExecuteQuery()


foreach($cc in $ctx.Web.ContentTypes){
if($cc.Hidden -eq $true){
Write-Host $cc.Name
}
}
}


# Paths to SDK. Please verify location on your computer.
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Expand All @@ -56,4 +40,4 @@ $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries"



Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl
Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl
Loading