Skip to content

Commit b13cfcc

Browse files
Merge branch 'develop' into pr/145
2 parents 3a39076 + 4586d1f commit b13cfcc

File tree

485 files changed

+16847
-8537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

485 files changed

+16847
-8537
lines changed

Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagement.ps1

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@
22
# Created by Arleta Wanat, 2015
33
#
44

5-
function Set-SPOListsContentTypesEnabled{
6-
param (
7-
[Parameter(Mandatory=$true,Position=1)]
8-
[string]$Username,
9-
[Parameter(Mandatory=$true,Position=2)]
10-
[string]$AdminPassword,
11-
[Parameter(Mandatory=$true,Position=3)]
12-
[string]$Url,
13-
[Parameter(Mandatory=$true,Position=4)]
14-
[bool]$ContentTypesEnabled
15-
)
16-
17-
$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
5+
function Set-SPOListsContentTypesEnabled {
6+
param (
7+
[Parameter(Mandatory = $true, Position = 1)]
8+
[string]$Username,
9+
[Parameter(Mandatory = $true, Position = 2)]
10+
[string]$AdminPassword,
11+
[Parameter(Mandatory = $true, Position = 3)]
12+
[string]$Url,
13+
[Parameter(Mandatory = $true, Position = 4)]
14+
[bool]$ContentTypesEnabled
15+
)
16+
17+
$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
1818

19-
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
20-
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
21-
$ctx.ExecuteQuery()
19+
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
20+
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
21+
$ctx.ExecuteQuery()
2222

23-
$Lists=$ctx.Web.Lists
23+
$Lists = $ctx.Web.Lists
2424

25-
$ctx.Load($Lists)
26-
$ctx.ExecuteQuery()
27-
28-
Foreach($ll in $Lists){
29-
$ll.ContentTypesEnabled = $ContentTypesEnabled
30-
$ll.Update()
31-
32-
try{
33-
$ctx.ExecuteQuery()
34-
Write-Host $ll.Title " Done" -ForegroundColor Green
35-
}
36-
catch [Net.WebException]{
37-
Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red
38-
}
39-
40-
}
25+
$ctx.Load($Lists)
26+
$ctx.ExecuteQuery()
27+
28+
Foreach ($ll in $Lists) {
29+
$ll.ContentTypesEnabled = $ContentTypesEnabled
30+
$ll.Update()
31+
32+
try {
33+
$ctx.ExecuteQuery()
34+
Write-Host $ll.Title " Done" -ForegroundColor Green
35+
}
36+
catch [Net.WebException] {
37+
Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red
38+
}
39+
40+
}
4141
}
4242

4343

@@ -47,10 +47,10 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens
4747
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
4848

4949
# Insert the credentials and the name of the site and the desired setting: $true or $false
50-
$Username="trial@trialtrial123.onmicrosoft.com"
51-
$AdminPassword="Pass"
52-
$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
53-
$ContentTypesEnabled=$true
50+
$Username = "trial@trialtrial123.onmicrosoft.com"
51+
$AdminPassword = "Pass"
52+
$Url = "https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
53+
$ContentTypesEnabled = $true
5454

5555

5656

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
A short Powershell script to allow management of content types for all lists and libraries in a site.
2+
3+
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%20a%20site/contentTypeManagement.png))
4+
5+
6+
Applies to lists and libraries.
7+
8+
9+
*It requires installed* [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=42038)
10+
11+
You have to enter the list information before running the script:
12+
13+
```PowerShell
14+
# Paths to SDK. Please verify location on your computer.
15+
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
16+
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
17+
18+
# Insert the credentials and the name of the site and the desired setting: $true for the content types management to be allowed or $false to disable it
19+
$Username="trial@trialtrial123.onmicrosoft.com"
20+
$AdminPassword="Pass"
21+
$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
22+
$ContentTypesEnabled=$true
23+
```
24+
25+
### Please share your thoughts in the Q&A section!
26+
27+
#### Related scripts</br>
28+
[Set direction of the reading order for a single list](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba)
29+
30+
[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795)
31+
32+
[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48)
33+
34+
[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157)
35+
36+
<br/><br/>
37+
<b>Enjoy and please share feedback!</b>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
A short Powershell script to allow management of content types for all SharePoint Online lists and libraries across all sites in a site collection
2+
3+
4+
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))
5+
6+
7+
Applies to lists and libraries.
8+
9+
10+
11+
*It requires installed* [SharePoint Online SDK](www.microsoft.com/en-us/download/details.aspx?id=42038)
12+
13+
You have to enter the list information before running the script:
14+
15+
```PowerShell
16+
17+
# Paths to SDK. Please verify location on your computer.
18+
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
19+
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
20+
21+
# Insert the credentials and the name of the site and the desired setting: $true for the content types management to be allowed or $false to disable it
22+
$Username="trial@trialtrial123.onmicrosoft.com"
23+
$AdminPassword="Pass"
24+
$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
25+
$ContentTypesEnabled=$true
26+
```
27+
28+
### Please share your thoughts in the Q&A section!
29+
30+
#### Wiki article with detailed code description:
31+
32+
33+
[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)
34+
35+
36+
37+
#### Related scripts
38+
[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba)
39+
40+
[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795)
41+
42+
[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48)
43+
44+
[Allow content type management for all lists in a site using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157)
45+
46+
[Set content type management setting for SharePoint Online list using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Set-content-type-39ae4bce)
47+
48+
49+
<br/><br/>
50+
<b>Enjoy and please share feedback!</b>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Short Powershell script to allow management of content types for a SharePoint Online list or library. It is an equivalent of **List**>>**List Settings**>>**Advanced**>>**Content types in User Interface Applies to lists and libraries**.
2+
3+
A short Powershell script to allow management of content types for a SharePoint Online list or library.
4+
5+
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/Set%20content%20type%20management%20setting%20for%20a%20single%20list/contentTypeManagement.png))
6+
7+
Applies to lists and libraries.
8+
9+
*It requires installed* [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=42038)
10+
11+
You have to enter the list information before running the script:
12+
13+
14+
15+
```PowerShell
16+
# Paths to SDK. Please verify location on your computer.
17+
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
18+
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
19+
20+
# Insert the credentials and the name of the site and list
21+
$Username="trial@trialtrial123.onmicrosoft.com"
22+
$AdminPassword="Pass"
23+
$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
24+
$ListName="Tasks list"
25+
$ContentTypesEnabled =$false
26+
```
27+
28+
29+
### Please share your thoughts in the Q&A section!
30+
31+
#### Wiki article with detailed code description:
32+
33+
[SharePoint Online: Turn on support for multiple content types in a list or library using Powershell](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)
34+
35+
#### Related scripts
36+
[Set direction of the reading order for a single list](https://gallery.technet.microsoft.com/office/Set-the-direction-of-the-f17ca66a)
37+
38+
[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba)
39+
40+
[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795)
41+
42+
[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48)
43+
44+
45+
46+
<br/><br/>
47+
<b>Enjoy and please share feedback!</b>
Lines changed: 51 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,68 @@
1-
function New-SPOContentType
2-
{
3-
param(
4-
[Parameter(Mandatory=$true,Position=1)]
5-
[string]$Username,
6-
[Parameter(Mandatory=$true,Position=2)]
7-
$AdminPassword,
8-
[Parameter(Mandatory=$true,Position=3)]
9-
[string]$Url,
10-
[Parameter(Mandatory=$true,Position=4)]
11-
[string]$Description,
12-
[Parameter(Mandatory=$true,Position=5)]
13-
[string]$Name,
14-
[Parameter(Mandatory=$true,Position=6)]
15-
[string]$Group,
16-
[Parameter(Mandatory=$true,Position=7)]
17-
[string]$ParentContentTypeID
1+
function New-SPOContentType {
2+
param(
3+
[Parameter(Mandatory = $true, Position = 1)]
4+
[string]$Username,
5+
[Parameter(Mandatory = $true, Position = 2)]
6+
$AdminPassword,
7+
[Parameter(Mandatory = $true, Position = 3)]
8+
[string]$Url,
9+
[Parameter(Mandatory = $true, Position = 4)]
10+
[string]$Description,
11+
[Parameter(Mandatory = $true, Position = 5)]
12+
[string]$Name,
13+
[Parameter(Mandatory = $true, Position = 6)]
14+
[string]$Group,
15+
[Parameter(Mandatory = $true, Position = 7)]
16+
[string]$ParentContentTypeID
17+
)
1818

19-
)
20-
21-
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
22-
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
23-
$ctx.Load($ctx.Web.Lists)
24-
$ctx.ExecuteQuery()
19+
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
20+
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
21+
$ctx.Load($ctx.Web.Lists)
22+
$ctx.ExecuteQuery()
2523

26-
2724

28-
$lci =New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
29-
$lci.Description=$Description
30-
$lci.Name=$Name
31-
#$lci.ID="0x0100aa862727aed04408b2599b25356e7000"
32-
$lci.ParentContentType=$ctx.Web.ContentTypes.GetById($ParentContentTypeID)
33-
$lci.Group=$Group
34-
35-
foreach($ll in $ctx.Web.Lists)
36-
{
3725

38-
$ctx.Load($ll.WorkflowAssociations)
39-
$ctx.ExecuteQuery()
26+
$lci = New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
27+
$lci.Description = $Description
28+
$lci.Name = $Name
29+
#$lci.ID="0x0100aa862727aed04408b2599b25356e7000"
30+
$lci.ParentContentType = $ctx.Web.ContentTypes.GetById($ParentContentTypeID)
31+
$lci.Group = $Group
4032

41-
if($ll.WorkflowAssociations.Count -gt 0)
42-
{
43-
$ContentType = $ll.ContentTypes.Add($lci)
44-
$ctx.Load($contentType)
45-
try
46-
{
47-
48-
$ctx.ExecuteQuery()
49-
Write-Host "Adding content type " $Name " to " $ll.Title
50-
}
51-
catch [Net.WebException]
52-
{
53-
Write-Host $_.Exception.ToString()
54-
}
33+
foreach ($ll in $ctx.Web.Lists) {
34+
$ctx.Load($ll.WorkflowAssociations)
35+
$ctx.ExecuteQuery()
5536

56-
57-
}
58-
}
37+
if ($ll.WorkflowAssociations.Count -gt 0) {
38+
$ContentType = $ll.ContentTypes.Add($lci)
39+
$ctx.Load($contentType)
40+
try {
41+
$ctx.ExecuteQuery()
42+
Write-Host "Adding content type " $Name " to " $ll.Title
43+
}
44+
catch [Net.WebException] {
45+
Write-Host $_.Exception.ToString()
46+
}
47+
}
48+
}
5949
}
6050

6151

6252

63-
# Paths to SDK. Please verify location on your computer.
53+
# Paths to SDK. Please verify location on your computer.
6454
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
6555
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
6656

6757
# Insert the credentials and the name of the admin site
68-
$Username="admin@tenant.onmicrosoft.com"
69-
$AdminPassword=Read-Host -Prompt "Password" -AsSecureString
70-
$AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlists"
71-
$Description="desc"
72-
$Name="From PS to Tasks234"
73-
$ParentContentTypeID="0x0107"
74-
$Group="List Content Types"
58+
$Username = "admin@tenant.onmicrosoft.com"
59+
$AdminPassword = Read-Host -Prompt "Password" -AsSecureString
60+
$AdminUrl = "https://tenant.sharepoint.com/sites/teamsitewithlists"
61+
$Description = "desc"
62+
$Name = "From PS to Tasks234"
63+
$ParentContentTypeID = "0x0107"
64+
$Group = "List Content Types"
7565

7666

7767

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

0 commit comments

Comments
 (0)