Skip to content

Commit d742b2b

Browse files
authored
Merge pull request #1 from PowershellScripts/develop
Pullnij sobie to wszystko
2 parents faa1ace + 54fc05e commit d742b2b

File tree

364 files changed

+8334
-3108
lines changed

Some content is hidden

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

364 files changed

+8334
-3108
lines changed
Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,47 @@
1-
21
#
32
# Created by Arleta Wanat, 2015
43
#
54

6-
function Set-SPOListsContentTypesEnabled
7-
{
8-
param (
9-
[Parameter(Mandatory=$true,Position=1)]
5+
function Set-SPOListsContentTypesEnabled{
6+
param (
7+
[Parameter(Mandatory=$true,Position=1)]
108
[string]$Username,
119
[Parameter(Mandatory=$true,Position=2)]
1210
[string]$AdminPassword,
13-
[Parameter(Mandatory=$true,Position=3)]
11+
[Parameter(Mandatory=$true,Position=3)]
1412
[string]$Url,
15-
[Parameter(Mandatory=$true,Position=4)]
13+
[Parameter(Mandatory=$true,Position=4)]
1614
[bool]$ContentTypesEnabled
17-
)
15+
)
1816

19-
$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
17+
$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
18+
2019
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
2120
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password)
2221
$ctx.ExecuteQuery()
2322

24-
$Lists=$ctx.Web.Lists
25-
$ctx.Load($Lists)
26-
$ctx.ExecuteQuery()
23+
$Lists=$ctx.Web.Lists
24+
25+
$ctx.Load($Lists)
26+
$ctx.ExecuteQuery()
2727

28-
Foreach($ll in $Lists)
29-
{
30-
$ll.ContentTypesEnabled = $ContentTypesEnabled
31-
$ll.Update()
32-
28+
Foreach($ll in $Lists){
29+
$ll.ContentTypesEnabled = $ContentTypesEnabled
30+
$ll.Update()
3331

34-
try
35-
{
36-
$ctx.ExecuteQuery()
37-
Write-Host $ll.Title " Done" -ForegroundColor Green
38-
}
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+
}
3939

40-
catch [Net.WebException]
41-
{
42-
43-
Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red
44-
}
45-
46-
}
40+
}
4741
}
4842

4943

5044

51-
52-
53-
54-
55-
56-
57-
5845
# Paths to SDK. Please verify location on your computer.
5946
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
6047
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
@@ -68,4 +55,4 @@ $ContentTypesEnabled=$true
6855

6956

7057

71-
Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled
58+
Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled
Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
A short Powershell script to allow management of content types for all lists and libraries in a site.
22

3-
4-
5-
It is an equivalent of List>>List Settings>>Advanced>>Content types in Graphic User Interface (see screenshot)
6-
7-
8-
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))
94

105

11-
12-
13-
14-
156
Applies to lists and libraries.
167

17-
18-
19-
208

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

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

25-
26-
27-
28-
2913
```PowerShell
3014
# Paths to SDK. Please verify location on your computer.
3115
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
@@ -38,18 +22,16 @@ $Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
3822
$ContentTypesEnabled=$true
3923
```
4024

41-
Please share your thoughts in the Q&A section!
42-
43-
25+
###Please share your thoughts in the Q&A section!
4426

45-
Related scripts
46-
Set direction of the reading order for a single list
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)
4729

48-
Set-SPOList properties (module)
30+
[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795)
4931

50-
Disable or enable attachments to list items using Powershell
32+
[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48)
5133

52-
Change search setting for all lists in a site using CSOM and Powershell
34+
[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157)
5335

5436
<br/><br/>
5537
<b>Enjoy and please share feedback!</b>

Content Types/Content Types Management Setting/Set content type management setting for a single list/description.md

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
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.
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**.
22

33
A short Powershell script to allow management of content types for a SharePoint Online list or library.
44

5-
6-
7-
It is an equivalent of List>>List Settings>>Advanced>>Content types in Graphic User Interface (see screenshot)
8-
9-
10-
11-
12-
13-
14-
15-
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))
166

177
Applies to lists and libraries.
188

19-
20-
21-
22-
23-
It requires installed SharePoint Online SDK
9+
*It requires installed* [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=42038)
2410

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

2713

2814

29-
PowerShell
15+
```PowerShell
3016
# Paths to SDK. Please verify location on your computer.
3117
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
3218
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
@@ -37,30 +23,23 @@ $AdminPassword="Pass"
3723
$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists"
3824
$ListName="Tasks list"
3925
$ContentTypesEnabled =$false
40-
41-
26+
```
4227

43-
4428

45-
Please share your thoughts in the Q&A section!
29+
### Please share your thoughts in the Q&A section!
4630

47-
48-
49-
Wiki article with detailed code description:
50-
31+
#### Wiki article with detailed code description:
5132

52-
SharePoint Online: Turn on support for multiple content types in a list or library using Powershell
53-
54-
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)
5534

56-
Related scripts
57-
Set direction of the reading order for a single list
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)
5837

59-
Set-SPOList properties (module)
38+
[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba)
6039

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

63-
Change search setting for all lists in a site using CSOM and Powershell
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)
6443

6544

6645

Content Types/Create/Add Content Type to Lists with Workflows/description.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ c) Instead of "https://tenant.sharepoint.com/sites/teamsitewithlibraries" enter
3939
d) Fill in the properties of the content type.
4040

4141

42-
43-
4442
5. Run the script in Powershell (any module).
4543

4644
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.
4745

48-
4946
<br/><br/>
5047
<b>Enjoy and please share feedback!</b>
Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,47 @@
1-
function New-SPOContentType
2-
{
3-
param(
4-
[Parameter(Mandatory=$true,Position=1)]
1+
function New-SPOContentType{
2+
param(
3+
[Parameter(Mandatory=$true,Position=1)]
54
[string]$Username,
65
[Parameter(Mandatory=$true,Position=2)]
76
$AdminPassword,
8-
[Parameter(Mandatory=$true,Position=3)]
7+
[Parameter(Mandatory=$true,Position=3)]
98
[string]$Url,
10-
[Parameter(Mandatory=$true,Position=4)]
9+
[Parameter(Mandatory=$true,Position=4)]
1110
[string]$Description,
12-
[Parameter(Mandatory=$true,Position=5)]
11+
[Parameter(Mandatory=$true,Position=5)]
1312
[string]$Name,
14-
[Parameter(Mandatory=$true,Position=6)]
13+
[Parameter(Mandatory=$true,Position=6)]
1514
[string]$Group,
16-
[Parameter(Mandatory=$true,Position=7)]
15+
[Parameter(Mandatory=$true,Position=7)]
1716
[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-
{
25+
$lci =New-Object Microsoft.SharePoint.Client.ContentTypeCreationInformation
26+
$lci.Description=$Description
27+
$lci.Name=$Name
28+
#$lci.ID="0x0100aa862727aed04408b2599b25356e7000"
29+
$lci.ParentContentType=$ctx.Web.ContentTypes.GetById($ParentContentTypeID)
30+
$lci.Group=$Group
3731

38-
if($ll.BaseTemplate -eq 107 -or $ll.BaseTemplate -eq 171)
39-
{
40-
$ContentType = $ll.ContentTypes.Add($lci)
41-
$ctx.Load($contentType)
42-
try
43-
{
44-
45-
$ctx.ExecuteQuery()
46-
Write-Host "Adding content type " $Name " to " $ll.Title
47-
}
48-
catch [Net.WebException]
49-
{
50-
Write-Host $_.Exception.ToString()
51-
}
52-
53-
54-
}
55-
}
32+
foreach($ll in $ctx.Web.Lists){
33+
if($ll.BaseTemplate -eq 107 -or $ll.BaseTemplate -eq 171){
34+
$ContentType = $ll.ContentTypes.Add($lci)
35+
$ctx.Load($contentType)
36+
try{
37+
$ctx.ExecuteQuery()
38+
Write-Host "Adding content type " $Name " to " $ll.Title
39+
}
40+
catch [Net.WebException]{
41+
Write-Host $_.Exception.ToString()
42+
}
43+
}
44+
}
5645
}
5746

5847

@@ -72,4 +61,4 @@ $Group="List Content Types"
7261

7362

7463

75-
New-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -Description $Description -Name $Name -Group $Group -ParentContentTypeID $ParentContentTypeID
64+
New-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl -Description $Description -Name $Name -Group $Group -ParentContentTypeID $ParentContentTypeID

0 commit comments

Comments
 (0)