From 9105bedfaddad80ecab5538435440c1a007a20d9 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Wed, 29 Jan 2020 23:46:25 +0100 Subject: [PATCH 01/22] Update description.md --- .../description.md | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md index bc34af8c..eec2be23 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md @@ -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. @@ -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)

From 2539ee7de7ecef197c92ccd831bf88183bdc38aa Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Wed, 29 Jan 2020 23:47:12 +0100 Subject: [PATCH 02/22] Update description.md --- .../description.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/description.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/description.md index a0d6f92d..fdc22124 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/description.md +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/description.md @@ -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
+#### Related scripts
[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) From 0f71c38dedec432b8b64503fddc0949bd0171f8e Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Wed, 29 Jan 2020 23:51:00 +0100 Subject: [PATCH 03/22] Update ContentTypeManagementSubsitesIncluded.ps1 --- .../ContentTypeManagementSubsitesIncluded.ps1 | 87 +++++++++---------- 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 index 9e762df4..71ad751b 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 @@ -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 - } - } - -} - @@ -80,4 +71,4 @@ $ContentTypesEnabled=$true -Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled \ No newline at end of file +Set-SPOListsContentTypesEnabled -Username $Username -AdminPassword $AdminPassword -Url $Url -ContentTypesEnabled $ContentTypesEnabled From 85cd2de4827115154e21c3bba4ca4d189f65ab04 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Thu, 30 Jan 2020 00:11:52 +0100 Subject: [PATCH 04/22] Update ListContentTypes.ps1 --- .../ListContentTypes.ps1 | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 index db6603cf..a18ba4af 100644 --- a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 +++ b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 @@ -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 @@ -77,4 +64,4 @@ $ContentTypesEnabled =$false Connect-SPOCSOM -Username $Username -AdminPassword $AdminPassword -Url $Url -Set-SPOList -ListName $ListName -ContentTypesEnabled $ContentTypesEnabled \ No newline at end of file +Set-SPOList -ListName $ListName -ContentTypesEnabled $ContentTypesEnabled From 480c48a1415d16797276a4e6d9b0717dd7786618 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Thu, 30 Jan 2020 00:48:17 +0100 Subject: [PATCH 05/22] Update description.md --- .../description.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Content Types/Create/Add Content Type to Lists with Workflows/description.md b/Content Types/Create/Add Content Type to Lists with Workflows/description.md index 29aee1dd..b97da707 100644 --- a/Content Types/Create/Add Content Type to Lists with Workflows/description.md +++ b/Content Types/Create/Add Content Type to Lists with Workflows/description.md @@ -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) @@ -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
+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.
- 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*.

Enjoy and please share feedback! From b3bc53f7b9c36b4d3de5113e16e15a007d47da6c Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 31 Jan 2020 00:30:13 +0100 Subject: [PATCH 06/22] Update GetCTNamesinAllLists.ps1 --- .../GetCTNamesinAllLists.ps1 | 74 +++++++------------ 1 file changed, 26 insertions(+), 48 deletions(-) diff --git a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 index d5c99a27..8eef5e5a 100644 --- a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 +++ b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 @@ -1,64 +1,42 @@  -function Get-SPOList -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] +function Get-SPOList{ + 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.Lists) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - foreach( $ll in $ctx.Web.Lists) - { + ) - $ctx.Load($ll.ContentTypes) + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) + $ctx.ExecuteQuery() - try - { - $ctx.ExecuteQuery() - } - catch - { - } + $ctx.Load($ctx.Web.Lists) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + foreach( $ll in $ctx.Web.Lists){ + $ctx.Load($ll.ContentTypes) - - - Write-Host $ll.Title -ForegroundColor Green - - foreach($cc in $ll.ContentTypes) - { - Write-Output $cc.Name - } + try{ + $ctx.ExecuteQuery() + } + catch{} - - + Write-Host $ll.Title -ForegroundColor Green - - - } - - - - } - - + foreach($cc in $ll.ContentTypes){ + Write-Output $cc.Name + } + } +} - - + # Paths to SDK. Please verify location on your computer. @@ -71,4 +49,4 @@ $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $AdminUrl="https://tenant.sharepoint.com/sites/teamsitewithlibraries" -Get-SPOList -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl \ No newline at end of file +Get-SPOList -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl From 48c51aa69736a9ecb39e902d441490763c78d427 Mon Sep 17 00:00:00 2001 From: PowershellScripts <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 11 Feb 2020 13:24:38 +0200 Subject: [PATCH 07/22] Update GetCTNamesinAllLists.ps1 --- .../GetCTNamesinAllLists.ps1 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 index 8eef5e5a..45c10140 100644 --- a/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 +++ b/Content Types/Get/Get Names of all content types added to your lists/GetCTNamesinAllLists.ps1 @@ -1,5 +1,3 @@ - - function Get-SPOList{ param ( [Parameter(Mandatory=$true,Position=1)] @@ -22,16 +20,17 @@ function Get-SPOList{ foreach( $ll in $ctx.Web.Lists){ $ctx.Load($ll.ContentTypes) - try{ - $ctx.ExecuteQuery() - } - catch{} + try{ + $ctx.ExecuteQuery() + } + catch{ + } Write-Host $ll.Title -ForegroundColor Green - foreach($cc in $ll.ContentTypes){ - Write-Output $cc.Name - } + foreach($cc in $ll.ContentTypes){ + Write-Output $cc.Name + } } } From 9f37fd0fbbb6e7cff94c715e6f1ee7d49c88bf0b Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Thu, 27 Feb 2020 23:36:07 +0100 Subject: [PATCH 08/22] Update description.md --- .../description.md | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md index e17f799d..ae4331ff 100644 --- a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md +++ b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/description.md @@ -1,22 +1,10 @@ -A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the Attach File icon under new item tab. If you disable the button, you and your users will not be able to add the attachments to list items. +A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the **Attach File** icon under **new item** tab. If you disable the button, you and your users will not be able to add the attachments to list items. -A short Powershell script to set the EnableAttachments property for a SharePoint Online list. The property is responsible for the Attach File icon under new item tab (see screenshot). The button allows you to add attachments to the list item. - - - - - - - - + If you disable the button, you and your users will not be able to add the attachments to list items: - - - - - + Applies to lists. @@ -24,7 +12,7 @@ Applies to lists. -It requires installed SharePoint Online SDK +It requires installed [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038) You have to enter the list information before running the script: @@ -45,18 +33,14 @@ $ListName="Tasks list" $Attachments =$false ``` -### Related scripts -Set direction of the reading order for a single list +## **Related scripts** +[Set direction of the reading order for a single list](https://gallery.technet.microsoft.com/office/Set-the-direction-of-the-f17ca66a) -Set-SPOList properties (module) - - - - +[Set-SPOList properties (module)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) -### Related article +## **Related article** -SharePoint Online: Disable or enable attachments to list items using Powershell +[SharePoint Online: Disable or enable attachments to list items using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/30024.sharepoint-online-disable-or-enable-attachments-to-list-items-using-powershell.aspx)

From a37898138e7ee68cf6c16318ad913e8920686564 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Thu, 27 Feb 2020 23:36:41 +0100 Subject: [PATCH 09/22] Update ListAttachments.ps1 --- .../ListAttachments.ps1 | 50 ++++++++----------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 index 275e2759..874aabc2 100644 --- a/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 +++ b/Items Management/Attachments/Enable or disable attachments to items of a chosen list/ListAttachments.ps1 @@ -1,57 +1,49 @@ - + # # Created by Arleta Wanat, 2015 # -function Set-SPOList -{ -param ( +function Set-SPOList{ + param ( [Parameter(Mandatory=$true,Position=0)] - [string]$ListName, + [string]$ListName, [Parameter(Mandatory=$true,Position=1)] - [bool]$Attachments - ) + [bool]$Attachments + ) -$ll=$ctx.Web.Lists.GetByTitle($ListName) + $ll=$ctx.Web.Lists.GetByTitle($ListName) -$ll.EnableAttachments = $Attachments - $ll.Update() + $ll.EnableAttachments = $Attachments + $ll.Update() - try - { + try{ $ctx.ExecuteQuery() Write-Host "Done" -ForegroundColor Green - } - - catch [Net.WebException] - { - - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red - } - - + } + 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)] [string]$Url -) + ) -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + $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=$ctx } @@ -78,4 +70,4 @@ $Attachments =$true Connect-SPOCSOM -Username $Username -AdminPassword $AdminPassword -Url $Url -Set-SPOList -ListName $ListName -Attachments $Attachments \ No newline at end of file +Set-SPOList -ListName $ListName -Attachments $Attachments From 43e208db2fa9372e75f0fb0535dbe2c1e6f7f6ed Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:40:57 +0100 Subject: [PATCH 10/22] Update description.md --- .../description.md | 43 ++++--------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/Items Management/Bulk update all items in a list/description.md b/Items Management/Bulk update all items in a list/description.md index 0396d756..2671eab5 100644 --- a/Items Management/Bulk update all items in a list/description.md +++ b/Items Management/Bulk update all items in a list/description.md @@ -1,41 +1,16 @@ Short Powershell script to bulk update all items in a list - - - +### **Example** - - -Example - - - - - - Result: + - - - - - +## **Requirements** - - - -Requirements - - - Before running the script, you have to modify the last lines! - - - - ```PowerShell # 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" @@ -45,18 +20,18 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens Update-SPOListItem -Username user@tenant.onmicrosoft.com -Url https://tenant.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "contacts list" -FieldToUpdate elp -ValueToUpdate bio ``` -Enter your credentials -FieldToUpdate specifies the name of the list column which you want to update -ValueToUpdate means the value that you want to enter in that column for each item -Verify if the SharePoint Online SDK is installed in the same location on your computer ++ Enter your credentials
++ FieldToUpdate specifies the name of the list column which you want to update
++ ValueToUpdate means the value that you want to enter in that column for each item
++ Verify if the [SharePoint Online SDK](https://www.microsoft.com/en-us/download/details.aspx?id=42038) is installed in the same location on your computer
Related Scripts -Powershell Module with Update-SPOListItem cmdlet +[Powershell Module with Update-SPOListItem cmdlet](https://gallery.technet.microsoft.com/scriptcenter/Powershell-Module-for-easy-5d590623)

-Enjoy and please share feedback! \ No newline at end of file +Enjoy and please share feedback! From 7e57412cb00c20d53e925ef54a4624005c1b368d Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:43:02 +0100 Subject: [PATCH 11/22] Update BulkUpdate.ps1 --- .../BulkUpdate.ps1 | 56 ++++++++----------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/Items Management/Bulk update all items in a list/BulkUpdate.ps1 b/Items Management/Bulk update all items in a list/BulkUpdate.ps1 index 03c51214..4e963d1c 100644 --- a/Items Management/Bulk update all items in a list/BulkUpdate.ps1 +++ b/Items Management/Bulk update all items in a list/BulkUpdate.ps1 @@ -1,20 +1,18 @@ - function Update-SPOListItem -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, - [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, -[Parameter(Mandatory=$true,Position=6)] - [string]$FieldToUpdate, -[Parameter(Mandatory=$true,Position=7)] - [string]$ValueToUpdate - ) +function Update-SPOListItem{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [string]$AdminPassword, + [Parameter(Mandatory=$true,Position=4)] + [string]$ListTitle, + [Parameter(Mandatory=$true,Position=6)] + [string]$FieldToUpdate, + [Parameter(Mandatory=$true,Position=7)] + [string]$ValueToUpdate + ) @@ -39,30 +37,24 @@ $count=$itemki.Count Write-Host $count - foreach($item in $itemki) - { - $item[$FieldToUpdate]=$ValueToUpdate + + foreach($item in $itemki){ + $item[$FieldToUpdate]=$ValueToUpdate $item.Update() - } - - try - { - $ctx.ExecuteQuery() - write-host " Success" + try{ + $ctx.ExecuteQuery() + write-host " Success" } - catch [Net.WebException] - { + catch [Net.WebException]{ Write-Host $_.Exception.ToString() -ForegroundColor Red - } - - } +} # 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" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" -Update-SPOListItem -Username user@domain.onmicrosoft.com -Url https://tenant.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "contacts list" -FieldToUpdate MyColumnName -ValueToUpdate SomeRandomValue \ No newline at end of file +Update-SPOListItem -Username user@domain.onmicrosoft.com -Url https://tenant.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "contacts list" -FieldToUpdate MyColumnName -ValueToUpdate SomeRandomValue From 1f797819398af4cebd102caf4ab7f427e66eb3a6 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:44:30 +0100 Subject: [PATCH 12/22] Update description.md --- .../description.md | 59 +++++++------------ 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/Items Management/Create new list item using Powershell/description.md b/Items Management/Create new list item using Powershell/description.md index 7c09a3b6..f1a9692b 100644 --- a/Items Management/Create new list item using Powershell/description.md +++ b/Items Management/Create new list item using Powershell/description.md @@ -2,58 +2,47 @@ Powershell Module with one new cmdlet -New-SPOListItem +## **New-SPOListItem** - - -Parameters +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of a site where you have the list - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's password - +```powershell [string]$ListTitle +``` Specifies the title of the list where you want to change the settings. - +```powershell [string]$ItemTitle +``` Specifies the title of the list item. In case of a contact list it will be the LastName, task list -> task name, etc. - +```powershell [string]$AdditionalField="" +``` Optional. If you want to add some additional attribute to the item at the moment of creation. For more attributes use Update-SPOListItem. This parameter defines the internal name of the column - +```powershell [string]$AdditionalValue="" +``` Optional. If you want to add some additional attribute to the item at the moment of creation. For more attributes use Update-SPOListItem. This parameter defines the value that you want to input. - - - - -Examples - - - - - - - - - - - - +### *Examples* -Requirements + -The following libraries (SharePoint Online SDK) are required. If those libraries are in different location on your computer, please edit the .psm1 file! +### *Requirements* - +The following libraries (SharePoint Online SDK) are required. If those libraries are in different location on your computer, please edit the ```.psm1``` file! ```PowerShell # Paths to SDK. Please verify location on your computer. @@ -61,12 +50,6 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" ``` - - - - - -

Enjoy and please share feedback! From 0e7c4f51669a95e55d6faec7709a46fdc7a56720 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:45:18 +0100 Subject: [PATCH 13/22] Update NewSPOListItem.psm1 --- .../NewSPOListItem.psm1 | 53 +++++++++---------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/Items Management/Create new list item using Powershell/NewSPOListItem.psm1 b/Items Management/Create new list item using Powershell/NewSPOListItem.psm1 index 8cf76cc3..fc64496c 100644 --- a/Items Management/Create new list item using Powershell/NewSPOListItem.psm1 +++ b/Items Management/Create new list item using Powershell/NewSPOListItem.psm1 @@ -1,23 +1,22 @@ -function New-SPOListItem -{ -param ( +function New-SPOListItem{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [string]$ItemTitle, -[Parameter(Mandatory=$false,Position=6)] - [string]$AdditionalField="", -[Parameter(Mandatory=$false,Position=7)] - [string]$AdditionalValue="" - ) - -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force + [string]$ItemTitle, + [Parameter(Mandatory=$false,Position=6)] + [string]$AdditionalField="", + [Parameter(Mandatory=$false,Position=7)] + [string]$AdditionalValue="" + ) + + $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.Load($ctx.Web) @@ -32,25 +31,21 @@ $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $listItem = $ll.AddItem($lici) $listItem["Title"]=$ItemTitle - if($AdditionalField -ne "") - { + + if($AdditionalField -ne ""){ $listItem[$AdditionalField]=$AdditionalValue } + $listItem.Update() $ll.Update() - try - { - - $ctx.ExecuteQuery() - Write-Host "Item " $ItemTitle " has been added to list " $ListTitle - } - catch [Net.WebException] - { + try{ + $ctx.ExecuteQuery() + Write-Host "Item " $ItemTitle " has been added to list " $ListTitle + } + catch [Net.WebException]{ Write-Host $_.Exception.ToString() - } - - + } } From 6376a30a3d0424b66c3dddd524d8a242a0b5d22e Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:46:51 +0100 Subject: [PATCH 14/22] Update description.md --- .../description.md | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/Items Management/Get the number of items in a list/description.md b/Items Management/Get the number of items in a list/description.md index b54e0377..c647cb03 100644 --- a/Items Management/Get the number of items in a list/description.md +++ b/Items Management/Get the number of items in a list/description.md @@ -1,29 +1,29 @@ New SharePoint Online Powershell cmdlet Get-SPOListItemCount which allows you to view the number of items in a list. -

Parameters

+## *Parameters* The cmdlet is using the following parameters: - - ```[string]$Username``` +```powershell + [string]$Username + ``` The string specifies admin of the site - -```[string]$Url``` +```powershell +[string]$Url +``` Specifies the url of a site where you have the list - -```[string]$AdminPassword``` +```powershell +[string]$AdminPassword +``` Admin's password - -```PowerShell[string]$ListTitle``` +```powershell +PowerShell[string]$ListTitle +``` Specifies the title of a list - - - - -

Requirements

+## *Requirements* @@ -37,13 +37,9 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens -

Examples

+## *Examples* - - - -

Enjoy and please share feedback! From 28b614259cf7b0eef63dd435ab07cb460023d1ab Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:47:14 +0100 Subject: [PATCH 15/22] Update GetSPOListItemCount.psm1 --- .../GetSPOListItemCount.psm1 | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/Items Management/Get the number of items in a list/GetSPOListItemCount.psm1 b/Items Management/Get the number of items in a list/GetSPOListItemCount.psm1 index 92ecf1ec..befd6e22 100644 --- a/Items Management/Get the number of items in a list/GetSPOListItemCount.psm1 +++ b/Items Management/Get the number of items in a list/GetSPOListItemCount.psm1 @@ -1,18 +1,14 @@ -function Get-SPOListItemCount -{ - - param ( +function Get-SPOListItemCount{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=3)] - [string]$ListTitle - ) - - + [string]$ListTitle + ) $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) @@ -25,8 +21,6 @@ $ctx.Load($ll) $ctx.ExecuteQuery() - - $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery $itemki=$ll.GetItems($spqQuery) @@ -34,12 +28,9 @@ $ctx.ExecuteQuery() $count=$itemki.Count - - + return $count - - - } +} # Paths to SDK. Please verify location on your computer. @@ -50,4 +41,4 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens -Export-ModuleMember -Function "Get-SPOListItemCount" \ No newline at end of file +Export-ModuleMember -Function "Get-SPOListItemCount" From 25f398058f73bb8b1718bfa673caa83eec074627 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:50:17 +0100 Subject: [PATCH 16/22] Update description.md --- .../description.md | 147 ++++++------------ 1 file changed, 48 insertions(+), 99 deletions(-) diff --git a/Items Management/GetSpoListItems and GetSPOListFields/description.md b/Items Management/GetSpoListItems and GetSPOListFields/description.md index 945327f9..18bec11b 100644 --- a/Items Management/GetSpoListItems and GetSPOListFields/description.md +++ b/Items Management/GetSpoListItems and GetSPOListFields/description.md @@ -1,176 +1,125 @@ 2 new SharePoint Online Powershell cmdlets to help you view items in a SharePoint Online list: - - - - - -

Get-SPOListItems

+

Get-SPOListItems

Retrieves all items in a given list

Parameters

- - The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of a site where you have the list - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's password - -[string]$ListName -ListName. To retrieve a table of list names, you can use Get-SPOList - +```powershell +[string]$ListName +``` +ListName. To retrieve a table of list names, you can use [Get-SPOList](https://gallery.technet.microsoft.com/scriptcenter/GetSPOList-Module-to-view-cc4d3e9e) +```powershell [bool]$IncludeAllProperties=$false +``` Specifies whether you should view all the available properties or just the Id and Title. By the default it is set to $false. - - - - - - The equivalent in Graphic User Interface (GUI) of this cmdlet would be a list view. - - -

Examples

+

Examples

-Get all items in an announcements list ++ Get all items in an announcements list ```powershell Get-SPOListItems -Username -Url -AdminPassword -ListName ``` + - - - -Get all items in a contacts list and their properties ++ Get all items in a contacts list and their properties ```powershell Get-SPOListItems -Username -Url -AdminPassword -ListName -IncludeAllProperties $true (example shows only one of multiple retrieved items) ``` - + Get all items in a list and their properties and export to CSV ```powershell Get-SPOListItems -Username -Url -AdminPassword -ListName -IncludeAllProperties $true | Export-CSV ``` - -Get all contacts from a contact list that belong to a specific company ++ Get all contacts from a contact list that belong to a specific company ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Contacts list" -IncludeAllProperties $true | where {$_.Company -eq "Uogiavv"} | select Title, Company ``` - + ++ Get all properties of a document as a list item* - - -Get all properties of a document as a list item* - - - - - - - + Get a list of all documents in a document library ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Documents" -IncludeAllProperties $true | select FileLeafRef ``` + - - - - - -Get a list of all documents in a document library, including folders and subfolders ++ Get a list of all documents in a document library, including folders and subfolders ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Documents" -IncludeAllProperties $true -Recursive | select FileLeafRef ``` - -Get a list of all Excel documents in a document library ++ Get a list of all Excel documents in a document library ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Documents" -IncludeAllProperties $true | where {$_.File_x0020_Type -eq "xlsx"} |select FileLeafRef ``` - - - + - - -Get a list of all Excel documents in a document library and export to CSV ++ Get a list of all Excel documents in a document library and export to CSV ```powershell Get-SPOListItems -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Documents" -IncludeAllProperties $true | where {$_.File_x0020_Type -eq "xlsx"} |select FileLeafRef | export-csv ``` - - - - - - - +
- - -

Get-SPOListFields

+## **Get-SPOListFields** Retrieves all columns in a given list. This includes hidden columns and excluded from views. - - - - - - -

Parameters

+

Parameters

The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of a site where you have the list - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's password +```powershell +[string]$ListName +``` -[string]$ListName - - - - -

Examples

+

Examples

-Get all fields of a links list ++ Get all fields of a links list ```powershell Get-SPOListFields -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com/sites/teamsitewithlists -AdminPassword Pass -ListTitle "Links list" ``` + +

Requirements

- - - - - - -

Requirements

- - - -The following libraries (SharePoint Online SDK) are required. If those libraries are in different location on your computer, please edit the .psm1 file! +The following libraries (SharePoint Online SDK) are required. If those libraries are in different location on your computer, please edit the ```.psm1``` file! ```powershell # Paths to SDK. Please verify location on your computer. @@ -180,6 +129,6 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens -Technicalities -Get-SPOListItems is using InternalName for item properties +### **Technicalities** +Get-SPOListItems is using InternalName for item properties
18.01.15 Added recursion and -Recursive switch parameter From 774d9149844c6a0944adafcbacbb63f60052cd9b Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:51:51 +0100 Subject: [PATCH 17/22] Update GetSPOListItems9.psm1 --- .../GetSPOListItems9.psm1 | 151 ++++++++---------- 1 file changed, 64 insertions(+), 87 deletions(-) diff --git a/Items Management/GetSpoListItems and GetSPOListFields/GetSPOListItems9.psm1 b/Items Management/GetSpoListItems and GetSPOListFields/GetSPOListItems9.psm1 index fe28d475..3af3c212 100644 --- a/Items Management/GetSpoListItems and GetSPOListFields/GetSPOListItems9.psm1 +++ b/Items Management/GetSpoListItems and GetSPOListFields/GetSPOListItems9.psm1 @@ -1,19 +1,18 @@ -function Get-SPOListFields -{ - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, - [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=3)] - [string]$ListTitle, - [Parameter(Mandatory=$false,Position=4)] - [bool]$IncludeSubsites=$false - ) - -$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force +function Get-SPOListFields{ + param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [string]$AdminPassword, + [Parameter(Mandatory=$true,Position=3)] + [string]$ListTitle, + [Parameter(Mandatory=$false,Position=4)] + [bool]$IncludeSubsites=$false + ) + + $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.Load($ctx.Web.Lists) @@ -26,53 +25,50 @@ $password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force $ctx.ExecuteQuery() - $fieldsArray=@() - $fieldslist=@() - foreach ($fiel in $ll.Fields) - { - #Write-Host $fiel.Description `t $fiel.EntityPropertyName `t $fiel.Id `t $fiel.InternalName `t $fiel.StaticName `t $fiel.Tag `t $fiel.Title `t $fiel.TypeDisplayName - - $array=@() - $array+="InternalName" - $array+="StaticName" - $array+="Tag" - $array+="Title" - - $obj = New-Object PSObject - $obj | Add-Member NoteProperty $array[0]($fiel.InternalName) - $obj | Add-Member NoteProperty $array[1]($fiel.StaticName) - $obj | Add-Member NoteProperty $array[2]($fiel.Tag) - $obj | Add-Member NoteProperty $array[3]($fiel.Title) - - $fieldsArray+=$obj - $fieldslist+=$fiel.InternalName - Write-Output $obj - } + $fieldsArray=@() + $fieldslist=@() + + foreach ($fiel in $ll.Fields){ + #Write-Host $fiel.Description `t $fiel.EntityPropertyName `t $fiel.Id `t $fiel.InternalName `t $fiel.StaticName `t $fiel.Tag `t $fiel.Title `t $fiel.TypeDisplayName + + $array=@() + $array+="InternalName" + $array+="StaticName" + $array+="Tag" + $array+="Title" + + $obj = New-Object PSObject + $obj | Add-Member NoteProperty $array[0]($fiel.InternalName) + $obj | Add-Member NoteProperty $array[1]($fiel.StaticName) + $obj | Add-Member NoteProperty $array[2]($fiel.Tag) + $obj | Add-Member NoteProperty $array[3]($fiel.Title) + + $fieldsArray+=$obj + $fieldslist+=$fiel.InternalName + Write-Output $obj + } $ctx.Dispose() return $fieldsArray - } -function Get-SPOListItems -{ - +function Get-SPOListItems{ param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, - [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, - [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, - [Parameter(Mandatory=$false,Position=5)] - [bool]$IncludeAllProperties=$false, - [switch]$Recursive - ) + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + [string]$AdminPassword, + [Parameter(Mandatory=$true,Position=4)] + [string]$ListTitle, + [Parameter(Mandatory=$false,Position=5)] + [bool]$IncludeAllProperties=$false, + [switch]$Recursive + ) @@ -91,62 +87,43 @@ function Get-SPOListItems - $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -# $spqQuery.ViewAttributes = "Scope='Recursive'" + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + # $spqQuery.ViewAttributes = "Scope='Recursive'" -if($Recursive) -{ -$spqQuery.ViewXml =""; -} + if($Recursive){ + $spqQuery.ViewXml =""; + } + $bobo=Get-SPOListFields -Username $Username -Url $Url -AdminPassword $AdminPassword -ListTitle $ListTitle - $itemki=$ll.GetItems($spqQuery) $ctx.Load($itemki) $ctx.ExecuteQuery() - - $objArray=@() - for($j=0;$j -lt $itemki.Count ;$j++) - { - + for($j=0;$j -lt $itemki.Count ;$j++){ $obj = New-Object PSObject - if($IncludeAllProperties) - { - - for($k=0;$k -lt $bobo.Count ; $k++) - { - + if($IncludeAllProperties){ + for($k=0;$k -lt $bobo.Count ; $k++){ # Write-Host $k $name=$bobo[$k].InternalName $value=$itemki[$j][$name] $obj | Add-Member NoteProperty $name($value) -Force - } - } - else - { + } + else{ $obj | Add-Member NoteProperty ID($itemki[$j]["ID"]) $obj | Add-Member NoteProperty Title($itemki[$j]["Title"]) - - } - + } # Write-Host $obj.ID `t $obj.Title $objArray+=$obj - - } - - return $objArray - - - } +} # Paths to SDK. Please verify location on your computer. @@ -157,4 +134,4 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens -Export-ModuleMember -Function "Get-SPOListItems", "Get-SPOListFields" \ No newline at end of file +Export-ModuleMember -Function "Get-SPOListItems", "Get-SPOListFields" From fc1941a59c7f8847595210574697e9c76b3395d4 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:52:57 +0100 Subject: [PATCH 18/22] Update description.md --- .../Module for item management/description.md | 227 +++++++----------- 1 file changed, 90 insertions(+), 137 deletions(-) diff --git a/Items Management/Module for item management/description.md b/Items Management/Module for item management/description.md index 2c3d9a30..7ee24a30 100644 --- a/Items Management/Module for item management/description.md +++ b/Items Management/Module for item management/description.md @@ -1,5 +1,5 @@ 5 cmdlets for item management: - + Update-SPOListItem Remove-SPOListItem @@ -9,254 +9,207 @@ Remove-SPOListItemPermissions Remove-SPOListItemInheritance Restore-SPOListItemInheritance - + -Update-SPOListItem +## **Update-SPOListItem** Updates a property of an item -Parameters - - +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username +``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID - +```powershell [string]$FieldToUpdate -Mandatory. Specifies the name of the field to update. In order to get the internal names of the fields (more often than not they are different from column titles), you can use Get-SPOListFields - +``` +Mandatory. Specifies the name of the field to update. In order to get the internal names of the fields (more often than not they are different from column titles), you can use [Get-SPOListFields](https://gallery.technet.microsoft.com/scriptcenter/GetSpoListItems-and-a8ecd5fa) +```powershell [string]$ValueToUpdate +``` Mandatory. Specifies the value of the field for this item - +
-Example: +## *Example:* -Change the name of an item (file in this example) - ++ Change the name of an item (file in this example) + -Update a column for all items using Get-SPOListItems cmdlet -(Here we will be updating Title column to be called "Title" + the item ID number ++ Update a column for all items using [Get-SPOListItems cmdlet](https://gallery.technet.microsoft.com/scriptcenter/GetSpoListItems-and-a8ecd5fa) +(Here we will be updating Title column to be called "Title" + the item ID number + And the result: + +
- - - - - - - - - - - - - - - - - - -Remove-SPOListItem +## **Remove-SPOListItem** Removes an item - - -Parameters - - +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID - - -Example: - - - -Remove the item no 16 located in one of the subfolders - - - - - +## *Example:* - - - - - - - - ++ Remove the item no 16 located in one of the subfolders - + -Remove-SPOListItemPermissions +## **Remove-SPOListItemPermissions** Removes all permissions for an item. Only the user running the cmdlet will have access - - -Parameters - - +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID -Example: +## *Example:* -Remove the permissions -Remove-SPOListItemPermissions -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ListTitle chc1 -ItemID 4 ++ Remove the permissions - - - - - - - +Remove-SPOListItemPermissions -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ListTitle chc1 -ItemID 4 - + - +
-Remove-SPOListItemInheritance +## **Remove-SPOListItemInheritance** Stops inheriting permissions for an item - - -Parameters - - +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID - +
- - - - -Restore-SPOListItemInheritance +## **Restore-SPOListItemInheritance** Deletes unique permissions for an item - - -Parameters +### *Parameters* The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$Url +``` Specifies the url of the site - +```powershell [string]$AdminPassword, +``` Admin's Password - +```powershell [string]$ListTitle +``` Mandatory. Specifies list title where the item is located - +```powershell [Int]$ItemID +``` Mandatory. Specifies item ID - - - - - - - - - - - - - - -Requirements +## *Requirements* From 31b7b08546820548c15e2ea06f299c04b55de374 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:53:34 +0100 Subject: [PATCH 19/22] Update description.md --- Items Management/Module for item management/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Items Management/Module for item management/description.md b/Items Management/Module for item management/description.md index 7ee24a30..62713602 100644 --- a/Items Management/Module for item management/description.md +++ b/Items Management/Module for item management/description.md @@ -1,5 +1,5 @@ 5 cmdlets for item management: - +
Update-SPOListItem Remove-SPOListItem From d81d2560cc3dfddb99b89a40436a8a51e8a13e13 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:54:48 +0100 Subject: [PATCH 20/22] Update SPOListItemFunctions.psm1 --- .../SPOListItemFunctions.psm1 | 210 ++++++++---------- 1 file changed, 92 insertions(+), 118 deletions(-) diff --git a/Items Management/Module for item management/SPOListItemFunctions.psm1 b/Items Management/Module for item management/SPOListItemFunctions.psm1 index 715d157e..8e8d9ed6 100644 --- a/Items Management/Module for item management/SPOListItemFunctions.psm1 +++ b/Items Management/Module for item management/SPOListItemFunctions.psm1 @@ -1,18 +1,16 @@ -function Remove-SPOListItemInheritance -{ - - param ( +function Remove-SPOListItemInheritance{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID - ) + [Int]$ItemID + ) @@ -29,42 +27,37 @@ $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -$spqQuery.ViewXml =""; + $spqQuery.ViewXml =""; $itemek=$ll.GetItemByID($ItemID) $ctx.Load($itemek) $ctx.ExecuteQuery() $itemek.BreakRoleInheritance($true, $false) - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - } + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } +} - function Remove-SPOListItemPermissions -{ - - param ( +function Remove-SPOListItemPermissions{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID - ) + [Int]$ItemID + ) @@ -81,42 +74,37 @@ $spqQuery.ViewXml =""; $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -$spqQuery.ViewXml =""; + $spqQuery.ViewXml =""; $itemek=$ll.GetItemByID($ItemID) $ctx.Load($itemek) $ctx.ExecuteQuery() $itemek.BreakRoleInheritance($false, $false) - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } -catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - } + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } +} - function Restore-SPOListItemInheritance -{ - - param ( +function Restore-SPOListItemInheritance{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID - ) + [Int]$ItemID + ) @@ -133,41 +121,35 @@ catch [Net.WebException] $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -$spqQuery.ViewXml =""; + $spqQuery.ViewXml =""; $itemek=$ll.GetItemByID($ItemID) $ctx.Load($itemek) $ctx.ExecuteQuery() $itemek.ResetRoleInheritance() - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } - catch [Net.WebException] - { + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ Write-Host $_.Exception.ToString() - } - - - } + } +} - function Remove-SPOListItem -{ - - param ( +function Remove-SPOListItem{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID - ) + [Int]$ItemID + ) @@ -184,48 +166,43 @@ $spqQuery.ViewXml =""; $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery -$spqQuery.ViewXml =""; + $spqQuery.ViewXml =""; $itemek=$ll.GetItemByID($ItemID) $ctx.Load($itemek) $ctx.ExecuteQuery() $itemek.DeleteObject() - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } -catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - } + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } +} - function Update-SPOListItem -{ - - param ( +function Update-SPOListItem{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle, + [string]$ListTitle, [Parameter(Mandatory=$true,Position=5)] - [Int]$ItemID, -[Parameter(Mandatory=$true,Position=6)] - [string]$FieldToUpdate, -[Parameter(Mandatory=$true,Position=7)] - [string]$ValueToUpdate - ) + [Int]$ItemID, + [Parameter(Mandatory=$true,Position=6)] + [string]$FieldToUpdate, + [Parameter(Mandatory=$true,Position=7)] + [string]$ValueToUpdate + ) @@ -250,18 +227,15 @@ catch [Net.WebException] $ctx.ExecuteQuery() $itemek[$FieldToUpdate] = $ValueToUpdate $itemek.Update() - try - { - $ctx.ExecuteQuery() - write-host $itemek.Name " Success" - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - - } + try{ + $ctx.ExecuteQuery() + write-host $itemek.Name " Success" + } + catch [Net.WebException]{ + Write-Host $_.Exception.ToString() + } +} # 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" From 638d1a460caa4c785e8eb822652fe44c037d5527 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:55:24 +0100 Subject: [PATCH 21/22] Update description.md --- .../description.md | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/Items Management/Remove permissions from SharePoint Online items/description.md b/Items Management/Remove permissions from SharePoint Online items/description.md index 3a7cd73c..42166af2 100644 --- a/Items Management/Remove permissions from SharePoint Online items/description.md +++ b/Items Management/Remove permissions from SharePoint Online items/description.md @@ -2,31 +2,15 @@ Powershell script to remove permissions for all items in a SharePoint Online lis As a result, only the user running this script will have access to the files. - - - - -Result - - - - - - +### *Result* - + - - - +
-Requirements +### *Requirements* -Before you run it, you have to modify the last line of the script! - - - - +**Before you run it, you have to modify the last line of the script!** ```PowerShell # Paths to SDK. Please verify location on your computer. @@ -36,11 +20,11 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens Remove-SPOListAllItemsInheritance -Username "trial@trialtrial123.onmicrosoft.com" -Url "https://trialtrial123.sharepoint.com" -AdminPassword "Pass" -ListTitle "chc1" ``` -Enter your credentials and the site where you want to modify the inheritance. -Verify if the SharePoint Online SDK is installed in the same location on your computer ++ Enter your credentials and the site where you want to modify the inheritance. ++ Verify if the [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=30722) is installed in the same location on your computer

-Enjoy and please share feedback!s \ No newline at end of file +Enjoy and please share feedback!s From aee4b14d964dc4f33c49b663b373bf59660ebef5 Mon Sep 17 00:00:00 2001 From: JakubPiegza <45433779+JakubPiegza@users.noreply.github.com> Date: Fri, 28 Feb 2020 00:56:00 +0100 Subject: [PATCH 22/22] Update RemovePermissionsFromItems.ps1 --- .../RemovePermissionsFromItems.ps1 | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Items Management/Remove permissions from SharePoint Online items/RemovePermissionsFromItems.ps1 b/Items Management/Remove permissions from SharePoint Online items/RemovePermissionsFromItems.ps1 index 459fc801..c2b6cb0e 100644 --- a/Items Management/Remove permissions from SharePoint Online items/RemovePermissionsFromItems.ps1 +++ b/Items Management/Remove permissions from SharePoint Online items/RemovePermissionsFromItems.ps1 @@ -1,17 +1,15 @@ <#Powershell script to remove permissions for all items in a SharePoint Online list. As a result, only the user running this script will have access to the files. Before you run it, you have to modify the last line of the script! #> -function Remove-SPOListAllItemsInheritance -{ - - param ( +function Remove-SPOListAllItemsInheritance{ + param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - [string]$Url, + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, [Parameter(Mandatory=$true,Position=3)] - [string]$AdminPassword, + [string]$AdminPassword, [Parameter(Mandatory=$true,Position=4)] - [string]$ListTitle - ) + [string]$ListTitle + ) @@ -36,15 +34,13 @@ function Remove-SPOListAllItemsInheritance $ctx.ExecuteQuery() - for($j=0;$j -lt $itemki.Count ;$j++) - { + for($j=0;$j -lt $itemki.Count ;$j++){ $itemki[$j].BreakRoleInheritance($false, $false) } - $ctx.ExecuteQuery() - } +} # Paths to SDK. Please verify location on your computer.