Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9105bed
Update description.md
JakubPiegza Jan 29, 2020
0f71c38
Update ContentTypeManagementSubsitesIncluded.ps1
JakubPiegza Jan 29, 2020
b3bc53f
Update GetCTNamesinAllLists.ps1
JakubPiegza Jan 30, 2020
48c51aa
Update GetCTNamesinAllLists.ps1
PowershellScripts Feb 11, 2020
d742b2b
Merge pull request #1 from PowershellScripts/develop
JakubPiegza Feb 26, 2020
9f37fd0
Update description.md
JakubPiegza Feb 27, 2020
a378981
Update ListAttachments.ps1
JakubPiegza Feb 27, 2020
1e7b953
Merge pull request #7 from JakubPiegza/patch-9
JakubPiegza Feb 27, 2020
be7ca5c
Merge pull request #6 from JakubPiegza/patch-7
JakubPiegza Feb 27, 2020
e31f9df
Merge pull request #5 from JakubPiegza/patch-6
JakubPiegza Feb 27, 2020
707a505
Merge pull request #4 from JakubPiegza/patch-5
JakubPiegza Feb 27, 2020
f1ba603
Merge pull request #3 from JakubPiegza/patch-53
JakubPiegza Feb 27, 2020
380e2e8
Merge pull request #2 from JakubPiegza/patch-4
JakubPiegza Feb 27, 2020
8661821
Update readme.md
JakubPiegza Feb 28, 2020
d12c72c
Update CheckingLicensesWithPlanType.ps1
JakubPiegza Feb 28, 2020
6312774
Update description.md
JakubPiegza Feb 28, 2020
4002938
Update CheckLicensesWithServiceName.ps1
JakubPiegza Feb 28, 2020
1c4b7f3
Update description.md
JakubPiegza Feb 28, 2020
4ffc948
Update GetLicensesProvisioningStatusDoubleLicenses.ps1
JakubPiegza Feb 28, 2020
35fd652
Update description.md
JakubPiegza Feb 28, 2020
8705dfc
Update GetLicensesProvisioningStatus.ps1
JakubPiegza Feb 28, 2020
1011c2b
Update description.md
JakubPiegza Feb 28, 2020
22fd0a6
Update NoSpoLicense.ps1
JakubPiegza Feb 28, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ $Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
$ContentTypesEnabled=$true
```

###Please share your thoughts in the Q&A section!
### Please share your thoughts in the Q&A section!

####Related scripts</br>
#### Related scripts</br>
[Set direction of the reading order for a single list](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba)

[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,52 @@
# Created by Arleta Wanat, 2015
#

function Set-SPOListsContentTypesEnabled
{
param (
[Parameter(Mandatory=$true,Position=1)]
function Set-SPOListsContentTypesEnabled{
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
[string]$AdminPassword,
[Parameter(Mandatory=$true,Position=3)]
[Parameter(Mandatory=$true,Position=3)]
[string]$Url,
[Parameter(Mandatory=$true,Position=4)]
[Parameter(Mandatory=$true,Position=4)]
[bool]$ContentTypesEnabled
)

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

$Lists=$ctx.Web.Lists
$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.Webs)
$ctx.Load($Lists)
$ctx.ExecuteQuery()

Foreach($ll in $Lists)
{
$ll.ContentTypesEnabled = $ContentTypesEnabled
$ll.Update()


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

catch [Net.WebException]
{

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

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

$Lists=$ctx.Web.Lists
$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.Webs)
$ctx.Load($Lists)
$ctx.ExecuteQuery()

Foreach($ll in $Lists){
$ll.ContentTypesEnabled = $ContentTypesEnabled
$ll.Update()

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

if($ctx.Web.Webs.Count -gt 0){
Write-Host "--"-ForegroundColor DarkGreen

for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++){
Set-SPOListsContentTypesEnabled -Username $Username -Url $ctx.Web.Webs[$i].Url -AdminPassword $AdminPassword -ContentTypesEnabled $ContentTypesEnabled
}
}

}

if($ctx.Web.Webs.Count -gt 0)
{
Write-Host "--"-ForegroundColor DarkGreen
for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++)
{
Set-SPOListsContentTypesEnabled -Username $Username -Url $ctx.Web.Webs[$i].Url -AdminPassword $AdminPassword -ContentTypesEnabled $ContentTypesEnabled
}
}

}




Expand All @@ -80,4 +71,4 @@ $ContentTypesEnabled=$true



Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled
Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
A short Powershell script to allow management of content types for all SharePoint Online lists and libraries across all sites in a site collection



It is an equivalent of List>>List Settings>>Advanced>>Content types in Graphic User Interface (see screenshot)







It is an equivalent of **List**>>**List Settings**>>**Advanced**>>**Content types in Graphic User Interface** ([see screenshot](https://github.com/PowershellScripts/AllGalleryScriptsSamples/blob/develop/Content%20Types/Content%20Types%20Management%20Setting/Allow%20content%20type%20management%20for%20all%20lists%20in%20site%20collection/contentTypeManagement.png))


Applies to lists and libraries.





It requires installed SharePoint Online SDK
*It requires installed* [SharePoint Online SDK](www.microsoft.com/en-us/download/details.aspx?id=42038)

You have to enter the list information before running the script:



```PowerShell

# Paths to SDK. Please verify location on your computer.
Expand All @@ -36,33 +24,26 @@ $AdminPassword="Pass"
$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
$ContentTypesEnabled=$true
```






Please share your thoughts in the Q&A section!


### Please share your thoughts in the Q&A section!

Wiki article with detailed code description:
#### Wiki article with detailed code description:


[SharePoint Online: Turn on support for multiple content types in a list or library using Powershell](http://social.technet.microsoft.com/wiki/contents/articles/30038.sharepoint-online-turn-on-support-for-multiple-content-types-in-a-list-or-library-using-powershell.aspx)



Related scripts
Set-SPOList properties (module)
#### Related scripts
[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba)

Disable or enable attachments to list items using Powershell
[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795)

Change search setting for all lists in a site using CSOM and Powershell
[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48)

Allow content type management for all lists in a site using Powershell
[Allow content type management for all lists in a site using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157)

Set content type management setting for SharePoint Online list using Powershell
[Set content type management setting for SharePoint Online list using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Set-content-type-39ae4bce)


<br/><br/>
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ http://social.technet.microsoft.com/wiki/contents/articles/31051.sharepoint-onli

### How to use?

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


1. Download and install SharePoint Online SDK.

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

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

Expand All @@ -33,15 +31,14 @@ $Name="Name of the Content Type2"
$ParentContentTypeID="0x01"
$Group="List Content Types"
```
a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths
b) Instead of "admin@tenant.onmicrosoft.com" enter you username
c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types
d) Fill in the properties of the content type.
a) Find on your computer where SharePoint.Clitent.dll and SharePoint.Client.Runtime.dll libraries are located and insert the correct paths</br>
b) Instead of "admin@tenant.onmicrosoft.com" enter you username</br>
c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter the name of the site collection where you want to find the content types</br>
d) Fill in the properties of the content type.</br>


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 Title of the List.
6. When the script has executed, Powershell will show a message *Content Type Name of the Content Type2 has been added to Title of the List*.

<br/><br/>
<b>Enjoy and please share feedback!</b>
Loading