From 5dfd5dafb0d02c93947af18e241e54a9838cb100 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 6 May 2022 10:36:30 +0200 Subject: [PATCH 01/97] Update README.md --- Items Management/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Items Management/README.md b/Items Management/README.md index 86082d1c..90e90e2d 100644 --- a/Items Management/README.md +++ b/Items Management/README.md @@ -1 +1,25 @@ Scripts related to updating, deleting, adding SharePoint list items + + + + * Attachments + * Add size of SharePoint item attachments to list view + * Copy all SharePoint Online list item attachments + * Copy list attachments to a separate library + * Delete all your list attachments (data loss involved) + * Disable or enable attachments to list items + * Enable or disable attachments to items of a chosen list + * Get size of attachments per SharePoint Online list item + * Get the size of all attachments in a list + * List all attachments from SharePoint Online list to CSV file + * List all SharePoint Online list items with attachments + * Bulk update all items in a list + * Create new list item using Powershell + * Get + * Get the number of items in a list + * GetSpoListItems and GetSPOListFields + * List 10 latest items a user has modified + * List 10 latest items a user has modified in SharePoint Server list + * List 5 latest items a user has created in list + * Module for item management + * Remove permissions from SharePoint Online items From 29b411e361727d20bfb462437d0b32efcbfc3048 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 8 May 2022 22:31:22 +0200 Subject: [PATCH 02/97] Update README.md --- Tenant Settings/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Tenant Settings/README.md b/Tenant Settings/README.md index 2413d9c4..1082d9a8 100644 --- a/Tenant Settings/README.md +++ b/Tenant Settings/README.md @@ -1 +1,19 @@ Scripts related to tenant settings + + + * Add BCC to all sharing invitations in OneDrive for Business + * Allow external sharing only with specific domains + * Block download of all files for guests in SharePoint with Powershell and CSOM + * Force external users to accept sharing invitations with the same account + * Get SharePoint Online tenant properties using Powershell and CSOM + * Globally set OneDrive for Business Access Requests and Members Can Share + * Hide OneDrive for Business Sync button using PS and CSOM + * Modify external sharing setting + * Notify OneDrive for Business owner if anonymous link to their content is created + * Notify OneDrive for Business owner if their content is reshared + * Prevent external users from resharing + * Report on SharePoint Online tenant properties + * Set Anonymous access for SPO tenant using PS and CSOM + * Set anonymous link access level for SPO tenant + * Set default link type for SharePoint Online tenant sharing settings + * Set expiration for anonymous links in SPO From f66c4f29a6720d9ad5669c4dd2220653ab39c0fb Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 9 May 2022 09:02:25 +0200 Subject: [PATCH 03/97] Update README.md --- OTHER/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OTHER/README.md b/OTHER/README.md index 9c558e35..df3785bb 100644 --- a/OTHER/README.md +++ b/OTHER/README.md @@ -1 +1 @@ -. +Scripts that I couldn't really fit in anywhere else From c996d19781ca96eba8221e92017cffc815073baf Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 9 May 2022 09:14:09 +0200 Subject: [PATCH 04/97] Update README.md --- Pages/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Pages/README.md b/Pages/README.md index a0dbc24c..328e1c68 100644 --- a/Pages/README.md +++ b/Pages/README.md @@ -1 +1,10 @@ Scripts related to SharePoint Online pages + + + * ClassicWebparts + * Delete all web parts from a single page + * Delete single web part + * Get all web parts and their details from a single page + * Report on all web parts in all site pages + * Remove comments on modern pages in entire SharePoint site + From f89811031858a4c9dc982cbd0cce2b9289250d0c Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 9 May 2022 09:14:38 +0200 Subject: [PATCH 05/97] Create readme.md --- Permissions/readme.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Permissions/readme.md diff --git a/Permissions/readme.md b/Permissions/readme.md new file mode 100644 index 00000000..3328c8ec --- /dev/null +++ b/Permissions/readme.md @@ -0,0 +1,18 @@ + + + + * C# + * Break Inheritance for all items in site + * Delete all unique permissions in site + * Get Items with Unique Permissions in site collection + * Get Lists with Unique Permissions + * Powershell + * Break role inheritance for a single list + * Delete unique permissions in all items in a large list (5000+ items) + * Get items with unique permissions SharePoint Server + * Get items, folders, lists with unique permissions (SharePoint Server 2013-2016) + * Remove permission groups from personal files + * Report on what permission group the user belongs to + + + From 3634191f41a6462b698dc9468471bb2abf3a62e1 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 9 May 2022 09:28:27 +0200 Subject: [PATCH 06/97] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c492bec..eb135622 100644 --- a/README.md +++ b/README.md @@ -476,7 +476,7 @@ Have an idea for a useful script? Can't find it here? Open an issue and let's di * Remove SPO subsite * Set theme of your SharePoint Online site * Site designs - * Verify where a site design is applied + * Verify where a site design is applied * Update locale id for all personal sites * Update the time zones in all personal sites From 416a56ce75e786ae43f3d293e42bec2bbd3cdb14 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 9 May 2022 09:28:33 +0200 Subject: [PATCH 07/97] Update readme.md --- Site Management/readme.md | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Site Management/readme.md b/Site Management/readme.md index 32a4f9b2..f967cf73 100644 --- a/Site Management/readme.md +++ b/Site Management/readme.md @@ -1 +1,59 @@ Scripts related to Site Management + + + + + * Access Requests + * Get SharePoint Online Access Requests Settings with REST API + * Get SharePoint Online Access Requests with REST API + * Get SharePoint Server 2013-2016 Access Requests with REST API + * Set RequestAccessEmail for all subsites in one site collection + * Add Supported Language for multiple site collections + * Add-SPOWeb & Remove-SPOWeb + * ChangeLog + * Create a report on all changes for all your site collections + * Create a report on all changes for one site collection + * Enable page editing when master page editing has been disabled for this site + * Export site collection properties using Powershell and CSOM + * Features + * Activate or deactivate a feature for a site and its subsites + * Activate or deactivate a site collection feature + * Activate or deactivate a SPO feature for a single site + * Activate or deactivate a SPO feature for direct subsites in site collection + * Add or Remove Site Features from all Personal Sites + * Get all features from a site + * Get all features from a site collection + * Get all site collections and their subsites + * Get all time zones from a site + * Get SharePoint Online Site Properties + * Get site groups from root and subsites + * Get unused SharePoint Online webs + * Get-SPOWeb to retrieve subsites and their properties + * Modify Web Inherited Permissions + * Navigation + * Create empty node (label) + * Get all quick launch nodes + * Powershell cmdlet Set-SpoWeb to manage site properties + * Recycle Bin + * Detailed report on all recycle bin items across all site collections + * Move items from first to second stage recycle bin + * Remove all items from second stage recycle bin (involves data loss) + * Remove permanently all items from recycle bins (data loss involved) + * Report on all deleted items across all site collections + * Report on deleted files within one site + * Restore All Files from a Given Site + * Restore all files, items, lists deleted by a single employee + * Restore all reycle bin items across all site collections + * Restore deleted items from a single subsite + * Restore one file from a Given Site + * Retrieve all reycle bin items across all site collections + * Retrieve all reycle bin items across all sites incl group sites + * SPServer + * Restore all files items lists deleted by a single employee + * Remove SPO subsite + * Set theme of your SharePoint Online site + * Site designs + * Verify where a site design is applied + * Update locale id for all personal sites + * Update the time zones in all personal sites + From d01d21f890c4a81b5f31138af963cce6600b8478 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 9 May 2022 09:28:59 +0200 Subject: [PATCH 08/97] Update readme.md --- Site Management/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Site Management/readme.md b/Site Management/readme.md index f967cf73..a7afb6a4 100644 --- a/Site Management/readme.md +++ b/Site Management/readme.md @@ -52,8 +52,8 @@ Scripts related to Site Management * Restore all files items lists deleted by a single employee * Remove SPO subsite * Set theme of your SharePoint Online site - * Site designs - * Verify where a site design is applied + * Site designs + * Verify where a site design is applied * Update locale id for all personal sites * Update the time zones in all personal sites From d85449340730b708db39aa3997c8b97662808b5b Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 10 May 2022 20:25:38 +0200 Subject: [PATCH 09/97] Update README.md --- Versioning/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Versioning/README.md b/Versioning/README.md index c4931169..a9d88041 100644 --- a/Versioning/README.md +++ b/Versioning/README.md @@ -1,9 +1,5 @@ Scripts related to versioning of the SharePoint files. - -
-Versioning -
* Create a report on all file versions in OneDrive for Business * Enable minor versions for all lists @@ -14,5 +10,4 @@ Scripts related to versioning of the SharePoint files. * Restore previous versions in the entire library * Set the major version limit for all the lists and libraries (data loss involved)
-
From f79ebcd553b3a7e70e1af5f17cc096c63a82450f Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 11 May 2022 23:42:26 +0200 Subject: [PATCH 10/97] Update README.md --- User Profiles/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/User Profiles/README.md b/User Profiles/README.md index 3e9d7d9e..0974af06 100644 --- a/User Profiles/README.md +++ b/User Profiles/README.md @@ -1 +1,8 @@ Scripts related to SharePoint user profiles. + + * Export all user profiles using Powershell + * Get all user profile properties using Powershell and REST + * Get MUI Languages for multiple users using REST + * Get user work email using Powershell and REST + * Retrieve all user profiles and their properties using C# and CSOM + From 8db2bf0e46fe4bb3d1e4001eb6b00a10be6bd890 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 13 May 2022 09:15:58 +0200 Subject: [PATCH 11/97] Create GetFlowsOlderOrNewerThan.md --- Power Automate/Get/GetFlows/GetFlowsOlderOrNewerThan.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Power Automate/Get/GetFlows/GetFlowsOlderOrNewerThan.md diff --git a/Power Automate/Get/GetFlows/GetFlowsOlderOrNewerThan.md b/Power Automate/Get/GetFlows/GetFlowsOlderOrNewerThan.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Power Automate/Get/GetFlows/GetFlowsOlderOrNewerThan.md @@ -0,0 +1 @@ +. From 99d6ef6c1a07b494ff7eddc36e9143091ae077d3 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 17 May 2022 07:52:47 +0200 Subject: [PATCH 12/97] Update README.md --- Workflows/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Workflows/README.md b/Workflows/README.md index c5f0d028..1df50bbe 100644 --- a/Workflows/README.md +++ b/Workflows/README.md @@ -1 +1,9 @@ Scripts dealing with SharePoint and Nintex workflows + + +* Get workflow report for a site collection +* Get workflow report for all site collections +* Get workflow report for one site +* Remove list workflow associations +* Remove workflow associations +* Remove workflow site associations From f94d66a999063b0158b12ba862e4fcb37b690980 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 17 May 2022 07:53:20 +0200 Subject: [PATCH 13/97] Create todo.md --- todo.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 todo.md diff --git a/todo.md b/todo.md new file mode 100644 index 00000000..f3b7df6b --- /dev/null +++ b/todo.md @@ -0,0 +1 @@ +workflow associations, missing code, readme From 46f0dda66c300aad68b6a3ed5c9b245f6e5255fa Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 17 May 2022 14:25:32 +0200 Subject: [PATCH 14/97] Delete removeWfs.ps1 --- Workflows/Remove workflow associations/removeWfs.ps1 | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Workflows/Remove workflow associations/removeWfs.ps1 diff --git a/Workflows/Remove workflow associations/removeWfs.ps1 b/Workflows/Remove workflow associations/removeWfs.ps1 deleted file mode 100644 index a1a7b990..00000000 --- a/Workflows/Remove workflow associations/removeWfs.ps1 +++ /dev/null @@ -1 +0,0 @@ -fdf From 8edce0ede9a27f65e3a0141ffb92b2baa5ef00b2 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 17 May 2022 14:25:46 +0200 Subject: [PATCH 15/97] Update README.md --- Workflows/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Workflows/README.md b/Workflows/README.md index 1df50bbe..5857090e 100644 --- a/Workflows/README.md +++ b/Workflows/README.md @@ -5,5 +5,4 @@ Scripts dealing with SharePoint and Nintex workflows * Get workflow report for all site collections * Get workflow report for one site * Remove list workflow associations -* Remove workflow associations * Remove workflow site associations From fd4e03483a8f83f4597595145bead858da996d1e Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 18 May 2022 19:45:35 +0200 Subject: [PATCH 16/97] Create readme.md --- Workflows/Remove list workflow associations/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Workflows/Remove list workflow associations/readme.md diff --git a/Workflows/Remove list workflow associations/readme.md b/Workflows/Remove list workflow associations/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Workflows/Remove list workflow associations/readme.md @@ -0,0 +1 @@ +. From 6cff68d4f0ec95b7b5dcaf1208f42eca2b825e24 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 24 May 2022 07:10:58 +0200 Subject: [PATCH 17/97] Update README.md --- Managed Metadata/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Managed Metadata/README.md b/Managed Metadata/README.md index e84f5917..570dbfdb 100644 --- a/Managed Metadata/README.md +++ b/Managed Metadata/README.md @@ -1 +1,6 @@ Cmdlets and scripts related to taxonomy. + + + * Create a new SharePoint Online taxonomy term + * Pull all groups, termsets, terms from your default SharePoint Online termstore + * Taxonomy cmdlets module to manage your term store in SharePoint Online From 21bbf58245dce762ed4313141997f76fe80ddf0b Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 25 May 2022 18:29:40 +0200 Subject: [PATCH 18/97] Create readme.md --- OneDrive for Business/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 OneDrive for Business/readme.md diff --git a/OneDrive for Business/readme.md b/OneDrive for Business/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/OneDrive for Business/readme.md @@ -0,0 +1 @@ +. From 31ff23d69bfc2334b1b7e4078710e1ff15deae49 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 22 Jun 2022 10:58:37 +0200 Subject: [PATCH 19/97] Create test.md --- test.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test.md diff --git a/test.md b/test.md new file mode 100644 index 00000000..f00cd50a --- /dev/null +++ b/test.md @@ -0,0 +1,8 @@ +> ### Agenda +> +> In this tutorial we will deal with: +> +> 1. TOC +> {:toc} +> +{: .agenda} From f4fbce5ca6aa2959ec3e840f7bab9d332fb6de44 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 22 Jun 2022 11:45:16 +0200 Subject: [PATCH 20/97] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eb135622..16ddd637 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ Have an idea for a useful script? Can't find it here? Open an issue and let's di
- *      Allow content type management for all lists in a site - *      Allow content type management for all lists in site collection - *      Set content type management setting for a single list + *      [Allow content type management for all lists in a site](https://github.com/PowershellScripts/SharePointOnline-ScriptSamples/tree/develop/Content%20Types/Content%20Types%20Management%20Setting/Allow%20content%20type%20management%20for%20all%20lists%20in%20a%20site) + *      [Allow content type management for all lists in site collection](https://github.com/PowershellScripts/SharePointOnline-ScriptSamples/tree/develop/Content%20Types/Content%20Types%20Management%20Setting/Allow%20content%20type%20management%20for%20all%20lists%20in%20site%20collection) + *      [Set content type management setting for a single list](https://github.com/PowershellScripts/SharePointOnline-ScriptSamples/tree/develop/Content%20Types/Content%20Types%20Management%20Setting/Set%20content%20type%20management%20setting%20for%20a%20single%20list) From b8d89ab38c416ac377548cddee3024281ef3f900 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 23 Jun 2022 17:04:08 +0200 Subject: [PATCH 21/97] Delete test.md --- test.md | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 test.md diff --git a/test.md b/test.md deleted file mode 100644 index f00cd50a..00000000 --- a/test.md +++ /dev/null @@ -1,8 +0,0 @@ -> ### Agenda -> -> In this tutorial we will deal with: -> -> 1. TOC -> {:toc} -> -{: .agenda} From 983c0cbffe0c866509113708be32c4b77621759b Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 1 Sep 2022 06:39:00 +0200 Subject: [PATCH 22/97] Create readme.md --- .../readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/readme.md diff --git a/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/readme.md b/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/readme.md @@ -0,0 +1 @@ +. From 6b0ccdba880e488874fd53a7b24b5f060355a3df Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 1 Sep 2022 06:39:18 +0200 Subject: [PATCH 23/97] Update description.md --- .../description.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/description.md b/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/description.md index f80806b3..ca81f389 100644 --- a/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/description.md +++ b/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/description.md @@ -16,7 +16,7 @@ The csv file contains itemID, item title and the name of the file. Each file is In order to use the script you need to modify the file: -PowerShell +```PowerShell # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" @@ -27,4 +27,4 @@ $Url = "https://etr56.sharepoint.com" $ListTitle = "attatest" $CSVPath = "C:\Users\Public\attachmentsreport.csv" - + ``` From 3ed742656ced377b60b1b6629bc8136397f7b779 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 1 Sep 2022 06:39:35 +0200 Subject: [PATCH 24/97] Update readme.md --- .../readme.md | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/readme.md b/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/readme.md index 9c558e35..ca81f389 100644 --- a/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/readme.md +++ b/Items Management/Attachments/List all attachments from SharePoint Online list to CSV file/readme.md @@ -1 +1,30 @@ -. +Powershell script lists all the item attachments from a SharePoint list and exports them to a csv file. + + + + + +The csv file contains itemID, item title and the name of the file. Each file is listed in a separate line (so items with several attachments will be listed several times, once per each file). + + + + + + + + + +In order to use the script you need to modify the file: + +```PowerShell +# Paths to SDK. Please verify location on your computer. +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" + +#Please enter your data +$Username = "ana@etr56.onmicrosoft.com" +$Url = "https://etr56.sharepoint.com" +$ListTitle = "attatest" +$CSVPath = "C:\Users\Public\attachmentsreport.csv" + + ``` From 4f6a42e38c07dc1ef4f3d43dcaa06ac60bf44485 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 19 Sep 2022 04:51:31 +0200 Subject: [PATCH 25/97] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 16ddd637..80aec137 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Over 200 SharePoint Online scripts The scripts use Powershell, C#, CSOM and REST. They include copies of existing scripts from Technet Gallery years 2013-2019. -Most of them were tested and verified by hundreds and thousands of users of [Technet Gallery, where you can still find these scripts](https://gallery.technet.microsoft.com/office/site/search?f%5B0%5D.Type=User&f%5B0%5D.Value=Arleta%20Wanat) +Most of them were tested and verified by hundreds and thousands of users of [Technet Gallery](https://gallery.technet.microsoft.com/office/site/search?f%5B0%5D.Type=User&f%5B0%5D.Value=Arleta%20Wanat) Their new home at GitHub is still relatively recent, so if you find any issues, please do let me know. I appreciate every comment and every feedback. From e90a3e98b73cd936669f5407aa9e905be7798ffa Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 7 Feb 2023 08:14:46 +0100 Subject: [PATCH 26/97] Create readme.md --- .../readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Permissions/Powershell/Get items with unique permissions SharePoint Server/readme.md diff --git a/Permissions/Powershell/Get items with unique permissions SharePoint Server/readme.md b/Permissions/Powershell/Get items with unique permissions SharePoint Server/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Permissions/Powershell/Get items with unique permissions SharePoint Server/readme.md @@ -0,0 +1 @@ +. From b36e0409be546cd5379afd54e80385b2c6b55d4d Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 7 Feb 2023 08:15:12 +0100 Subject: [PATCH 27/97] Update readme.md --- .../readme.md | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Permissions/Powershell/Get items with unique permissions SharePoint Server/readme.md b/Permissions/Powershell/Get items with unique permissions SharePoint Server/readme.md index 9c558e35..b8a4f361 100644 --- a/Permissions/Powershell/Get items with unique permissions SharePoint Server/readme.md +++ b/Permissions/Powershell/Get items with unique permissions SharePoint Server/readme.md @@ -1 +1,25 @@ -. +Short script to get the number of items with unique permissions per list. The scripts loops through all the lists in a single web and finds items with unique permissions. The items and their properties also get exported to a csv file. + + + + + + + +Before running the script, you need to open the file and enter correct information: + + + +```PowerShell +$webUrl="Enter here the url of your site, e.g. https://intra.Company.com" +$pathToExportReport="c:\MyCSV.csv" +``` + + +End results: + + + + + +The script requires SharePoint Management Shell. From 228a098fa1b1f0926c269d80e43e949b72f3f9f4 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 10 Feb 2023 20:18:49 +0100 Subject: [PATCH 28/97] Update README.md --- .../README.md | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/OneDrive for Business/Globally set OneDrive for Business Access Requests and Members Can Share/README.md b/OneDrive for Business/Globally set OneDrive for Business Access Requests and Members Can Share/README.md index 9c558e35..7a13599f 100644 --- a/OneDrive for Business/Globally set OneDrive for Business Access Requests and Members Can Share/README.md +++ b/OneDrive for Business/Globally set OneDrive for Business Access Requests and Members Can Share/README.md @@ -1 +1,44 @@ -. +Short Powershell script that modifies the following settings on every user's OneDrive for Business: + + + + + +On- Users with edit permissions can re-share. + +Off- Only OneDrive for Business owner can share. The value of ODBAccessRequestsdefines whether a request to share gets sent to the owner. + +Unspecified- Let each OneDrive for Business owner enable or disable re-sharing behavior on their OneDrive. + + + + + +The script is part of Technet Wiki article OneDrive for Business sharing settings with Powershell. + +## How to use? +Download and open the .ps1 file. +Add correct SharePoint Online SDK libraries: + + +```PowerShell +#Paths to SDK +Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` Enter the correct url, the setting for the sync button, and admin login. You will be additionally prompted for the password. Do not enter it in the file: +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$ODBMembersCanShare="On" # On, Off, Unspecified +$ODBAccessRequests="Unspecified" #On, Off, Unspecified +``` + + + Run the script + + + + + From 2af113568f76ef0e31dfb83a58db15d01c86dfb4 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 19 Feb 2023 15:52:48 +0100 Subject: [PATCH 29/97] Create readme.md --- .../Get Names of all content types added to your lists/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Content Types/Get/Get Names of all content types added to your lists/readme.md diff --git a/Content Types/Get/Get Names of all content types added to your lists/readme.md b/Content Types/Get/Get Names of all content types added to your lists/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Content Types/Get/Get Names of all content types added to your lists/readme.md @@ -0,0 +1 @@ +. From 5e23f0003f753417b1e9f6d4471a6d41fae7ce99 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 19 Feb 2023 15:53:05 +0100 Subject: [PATCH 30/97] Create readme.md --- .../Get/Get Content Types Derived From One Parent/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Content Types/Get/Get Content Types Derived From One Parent/readme.md diff --git a/Content Types/Get/Get Content Types Derived From One Parent/readme.md b/Content Types/Get/Get Content Types Derived From One Parent/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Content Types/Get/Get Content Types Derived From One Parent/readme.md @@ -0,0 +1 @@ +. From a5fd27a6579217255580f11fd7989eee89309486 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:28:48 +0100 Subject: [PATCH 31/97] Update readme.md --- .../readme.md | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/Content Types/Get/Get Content Types Derived From One Parent/readme.md b/Content Types/Get/Get Content Types Derived From One Parent/readme.md index 9c558e35..3697ef51 100644 --- a/Content Types/Get/Get Content Types Derived From One Parent/readme.md +++ b/Content Types/Get/Get Content Types Derived From One Parent/readme.md @@ -1 +1,57 @@ -. +The script below is described in the article [SharePoint Online content types in Powershell: Get](https://social.technet.microsoft.com/wiki/contents/articles/31151.sharepoint-online-content-types-in-powershell-get.aspx) and is part of various options on retrieving a single Content Type. + +It retrieves the content types that derive from specific a specific content type, in the example below it is Audio. In this script the content type is recognized by its ID. If you need a script where the parent content type will be recognized by its name, view [this link](https://gallery.technet.microsoft.com/Get-Content-Types-Derived-a0e749de). + +For 50+ other scripts refering to various content type functions, please click [View contributions](https://gallery.technet.microsoft.com/site/search?f%5B0%5D.Type=User&f%5B0%5D.Value=Arleta%20Wanat). + + +Before running the script, you need to open the file and edit the following lines, entering the Admin username, the site where you want to retrieve the content types, and the id of the content type. Do not enter the password - you will be prompted for it during the script execution. + + + +```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" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/powie1" +$Parent="0x0101009148F5A04DDD49CBA7127AADA5FB792B006973ACD696DC4858A76371B2FB2F439A" +``` + + + + +For other scripts related to Content Types, you can refer to the article [Wiki: SharePoint Online content types in Powershell: Add (en-us)](https://social.technet.microsoft.com/wiki/contents/articles/31051.sharepoint-online-content-types-in-powershell-add.aspx) + +*

Adding

* +[SharePoint Online: Create a content type using Powershell](https://gallery.technet.microsoft.com/SharePoint-Online-Create-a-2a4d3057)
+[Create content type and add directly to SPO list using Powershell ](https://gallery.technet.microsoft.com/Create-content-type-and-c5332edb)
+[Create and add content type to a content type hub SharePoint Online ](https://gallery.technet.microsoft.com/Create-and-add-content-f9e8eb6f)
+[Create content type and add it to all lists in one site ](https://gallery.technet.microsoft.com/Create-content-type-and-d41ece6e)
+[Add Content Type to Task Lists ](https://gallery.technet.microsoft.com/Add-Content-Type-to-Task-253d3966)
+[Add Content Type to Lists with Workflows ](https://gallery.technet.microsoft.com/Add-Content-Type-to-Lists-503bd493)
+[Add existing content type directly to SPO list using Powershell ](https://gallery.technet.microsoft.com/Add-existing-content-type-e2cbe9b9)
+ +*

Content Type Management

* +[Allow content type management for all lists in site collection using Powershell ](https://gallery.technet.microsoft.com/Allow-content-type-de3a5a09)
+[Allow content type management for all lists in a site using Powershell ](https://gallery.technet.microsoft.com/Allow-content-type-5bca5157)
+[Set content type management setting for SharePoint Online list using Powershell ](https://gallery.technet.microsoft.com/Set-content-type-39ae4bce)
+[Custom Powershell cmdlet Set-SPOList -ContentTypesEnabled ](https://gallery.technet.microsoft.com/SharePoint-Module-for-5ecbbcf0)
+ +*

Related Scripts

* +[SharePoint Online: Check content types added to your lists ](https://gallery.technet.microsoft.com/SharePoint-Online-Check-052fbdca)
+[SharePoint Online: Check content types added to your lists (recursive) ](https://gallery.technet.microsoft.com/SharePoint-Online-Check-e2650578)
+[Get a report on lists where a given content type is added ](https://gallery.technet.microsoft.com/Get-a-report-on-lists-c2decb62)
+[SharePoint Online: Remove a content type from all lists in a site collection ](https://gallery.technet.microsoft.com/SharePoint-Online-Remove-a-3a19f5b5)
+ +[Get all properties of all content types in a SharePoint site ](https://gallery.technet.microsoft.com/Get-all-properties-of-all-3a9c5c4bhttps://gallery.technet.microsoft.com/Get-all-properties-of-all-3a9c5c4b)
+[Get All Properties of All Content Types (Detailed) ](https://gallery.technet.microsoft.com/Get-All-Properties-of-All-a067d4f2)
+[Get All Properties of All Content Types in All Lists (Detailed) across one site ](https://gallery.technet.microsoft.com/Get-All-Properties-of-All-6e7de504)
+[Get properties of a single content type by its ID ](https://gallery.technet.microsoft.com/Get-properties-of-a-single-eb8020a7) + + +

+Enjoy and please share feedback! From 21217a847f384aae7bf026a979fcdb72b1f032f5 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 22 Feb 2023 13:48:20 +0100 Subject: [PATCH 32/97] Update description.md --- .../Get SPO Folder and File/description.md | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/File Management/Get SPO Folder and File/description.md b/File Management/Get SPO Folder and File/description.md index 3bac4e0d..df2d99a1 100644 --- a/File Management/Get SPO Folder and File/description.md +++ b/File Management/Get SPO Folder and File/description.md @@ -1,10 +1,10 @@ SharePoint Online Module with 2 new cmdlets: - +```powershell Get-SPOFolderByServerRelativeUrl Get-SPOFileByServerRelativeUrl - + ``` @@ -16,33 +16,37 @@ Get-SPOFileByServerRelativeUrl -Parameters +

Parameters

The cmdlet is using the following parameters: - +```powershell [string]$Username + ``` The string specifies admin of the site - +```powershell [string]$ParentUrl +``` Specifies the url of the parent site - -[string]$AdminPassword, +```powershell +[string]$AdminPassword +``` Admin's Password - +```powershell [string]$ServerRelativeUrl +``` Specifies the relative url of a file/folder -Examples +

Examples

Get a file -PS C:\Windows\system32> Get-SPOFileByServerRelativeUrl -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ServerRelativeUrl "/chc1/perm.txt" - + Get-SPOFileByServerRelativeUrl -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ServerRelativeUrl "/chc1/perm.txt" +``` @@ -50,8 +54,9 @@ PS C:\Windows\system32> Get-SPOFileByServerRelativeUrl -Username trial@trialtria Get folders +```powershell Get-SPOFolderByServerRelativeUrl -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ServerRelativeUrl "/chc1" - +``` @@ -60,26 +65,17 @@ Get-SPOFolderByServerRelativeUrl -Username trial@trialtrial123.onmicrosoft.com -

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 +```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" 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! \ No newline at end of file +Enjoy and please share feedback! From 7ba36fd0a08c0831ede882186696eb31af8faad4 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 24 Feb 2023 18:18:58 +0100 Subject: [PATCH 33/97] Update description.md --- File Management/Get SPO Folder and File/description.md | 1 + 1 file changed, 1 insertion(+) diff --git a/File Management/Get SPO Folder and File/description.md b/File Management/Get SPO Folder and File/description.md index df2d99a1..10f9b774 100644 --- a/File Management/Get SPO Folder and File/description.md +++ b/File Management/Get SPO Folder and File/description.md @@ -45,6 +45,7 @@ Specifies the relative url of a file/folder Get a file +```powershell Get-SPOFileByServerRelativeUrl -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ServerRelativeUrl "/chc1/perm.txt" ``` From 1722e2663244239d0c63329b3596d1674dbcf28a Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 27 Feb 2023 14:53:54 +0100 Subject: [PATCH 34/97] Update README.md --- .../Get SPO Folder and File/README.md | 83 ++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/File Management/Get SPO Folder and File/README.md b/File Management/Get SPO Folder and File/README.md index 9c558e35..10f9b774 100644 --- a/File Management/Get SPO Folder and File/README.md +++ b/File Management/Get SPO Folder and File/README.md @@ -1 +1,82 @@ -. +SharePoint Online Module with 2 new cmdlets: + + +```powershell +Get-SPOFolderByServerRelativeUrl +Get-SPOFileByServerRelativeUrl + ``` + + + + + +Get-SPOFolderByServerRelativeUrl + +Get-SPOFileByServerRelativeUrl + + + +

Parameters

+ +The cmdlet is using the following parameters: +```powershell + [string]$Username + ``` +The string specifies admin of the site +```powershell +[string]$ParentUrl +``` +Specifies the url of the parent site +```powershell +[string]$AdminPassword +``` +Admin's Password +```powershell +[string]$ServerRelativeUrl +``` +Specifies the relative url of a file/folder + + + + + +

Examples

+ + + +Get a file +```powershell + Get-SPOFileByServerRelativeUrl -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ServerRelativeUrl "/chc1/perm.txt" +``` + + + + + + +Get folders +```powershell +Get-SPOFolderByServerRelativeUrl -Username trial@trialtrial123.onmicrosoft.com -Url https://trialtrial123.sharepoint.com -AdminPassword Pass -ServerRelativeUrl "/chc1" +``` + + + + + + +

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. +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" +``` + + + + + +

+Enjoy and please share feedback! From dda78e58d97cfe9f48dd546a801f01c49f853ee6 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 1 Mar 2023 18:34:37 +0100 Subject: [PATCH 35/97] Create readme.md --- .../readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 OneDrive for Business/Hide OneDrive for Business Sync button using PS and CSOM/readme.md diff --git a/OneDrive for Business/Hide OneDrive for Business Sync button using PS and CSOM/readme.md b/OneDrive for Business/Hide OneDrive for Business Sync button using PS and CSOM/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/OneDrive for Business/Hide OneDrive for Business Sync button using PS and CSOM/readme.md @@ -0,0 +1 @@ +. From 61e819b86006a8619d5f717cf0a96d96c96ebe97 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 16 Mar 2023 19:20:41 +0100 Subject: [PATCH 36/97] Update readme.md --- .../readme.md | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/OneDrive for Business/Hide OneDrive for Business Sync button using PS and CSOM/readme.md b/OneDrive for Business/Hide OneDrive for Business Sync button using PS and CSOM/readme.md index 9c558e35..d2189e8a 100644 --- a/OneDrive for Business/Hide OneDrive for Business Sync button using PS and CSOM/readme.md +++ b/OneDrive for Business/Hide OneDrive for Business Sync button using PS and CSOM/readme.md @@ -1 +1,34 @@ -. +Short Powershell script that hides Sync button in OneDrive for Business for all users. + + + +The script uses CSOM and requires SharePoint Online SDK. + + + +This button will be removed with the script: + + + +### How to use? +- Download and open the ```.ps1``` file. +- Add correct SharePoint Online SDK libraries: + +```PowerShell +#Paths to SDK +Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "C:\Program Files\SharePoint Client Components\16.0\Assemblies\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` + +- Enter the correct url, the setting for the sync button, and admin login. You will be additionally prompted for the password. Do not enter it in the file: + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="arleta@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$HideSyncButtonOnODB=$true #Whether the sync button should be hidden +``` + +- Run the script + From dfcab13d07475b181d6c79791ef38075c23f1b9e Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 5 May 2023 14:56:32 +0200 Subject: [PATCH 37/97] Create readme.md --- Site Management/Access Requests/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Site Management/Access Requests/readme.md diff --git a/Site Management/Access Requests/readme.md b/Site Management/Access Requests/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Site Management/Access Requests/readme.md @@ -0,0 +1 @@ +. From ed0c1f329d037d1bc9286a292338b3ab61080117 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 5 May 2023 14:56:52 +0200 Subject: [PATCH 38/97] Update readme.md --- Site Management/Access Requests/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site Management/Access Requests/readme.md b/Site Management/Access Requests/readme.md index 9c558e35..32c0edd1 100644 --- a/Site Management/Access Requests/readme.md +++ b/Site Management/Access Requests/readme.md @@ -1 +1 @@ -. +Scripts related to managing access requests From 8f5deaf5e04b48640859deca1146124e2c6eba44 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 7 Jun 2023 11:34:24 +0200 Subject: [PATCH 39/97] Create readme.md --- .../readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Site Management/Get-SPOWeb to retrieve subsites and their properties/readme.md diff --git a/Site Management/Get-SPOWeb to retrieve subsites and their properties/readme.md b/Site Management/Get-SPOWeb to retrieve subsites and their properties/readme.md new file mode 100644 index 00000000..61780798 --- /dev/null +++ b/Site Management/Get-SPOWeb to retrieve subsites and their properties/readme.md @@ -0,0 +1 @@ +b From a9fcb00f94de44d83d9ccfeeaf495005bf048f05 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 12 Jun 2023 11:50:03 +0200 Subject: [PATCH 40/97] Update readme.md --- .../readme.md | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/Site Management/Get-SPOWeb to retrieve subsites and their properties/readme.md b/Site Management/Get-SPOWeb to retrieve subsites and their properties/readme.md index 61780798..77d8bbaf 100644 --- a/Site Management/Get-SPOWeb to retrieve subsites and their properties/readme.md +++ b/Site Management/Get-SPOWeb to retrieve subsites and their properties/readme.md @@ -1 +1,66 @@ -b +The cmdlet **Get-SPOWeb** retrieves subsites and their properties + +## Parameters + +The cmdlet is using the following parameters: + +- [string]$Username + +The string specifies admin of the site + +- [string]$Url + +Specifies the url of the parent site + +- [string]$AdminPassword, + +Admin's password + +- [bool]$IncludeSubsites=$false + +Specifies whether the sub-subsites and subs-subsubsites should be included as well. By default set to $false. + +## Examples + +- Get the subsites and their properties + +Get-SPOWeb -Username trial@trialtrial123.onmicrosoft.com -AdminPassword Pass -Url https://trialtrial123.sharepoint.com + + + +- Get the subsites and the sub-subsites + +Get-SPOWeb -Username trial@trialtrial123.onmicrosoft.com -AdminPassword Pass -Url https://trialtrial123.sharepoint.com -IncludeSubsites $true | select url + + + +- Get properties of a site in the site collection + +Get-SPOWeb -Username trial@trialtrial123.onmicrosoft.com -AdminPassword Pass -Url https://trialtrial123.sharepoint.com -IncludeSubsites $true | where {$_.Title -eq "SomeTitle"} + + + +- Get all sites in a site collecton based on some criteria + +Get-SPOWeb -Username trial@trialtrial123.onmicrosoft.com -AdminPassword Pass -Url https://trialtrial123.sharepoint.com -IncludeSubsites $true | where {$_.Language -eq 1033} | select url + + + +

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. +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" + ``` + + + + + + +### Let me know about your experience in the Q&A section! From 13445aa98d4b154926cf8d371c1d59d2d358de71 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 21 Jun 2023 08:35:32 +0200 Subject: [PATCH 41/97] Create readme.md --- .../readme.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Site Management/Access Requests/Get SharePoint Online Access Requests Settings with REST API/readme.md diff --git a/Site Management/Access Requests/Get SharePoint Online Access Requests Settings with REST API/readme.md b/Site Management/Access Requests/Get SharePoint Online Access Requests Settings with REST API/readme.md new file mode 100644 index 00000000..a433e92b --- /dev/null +++ b/Site Management/Access Requests/Get SharePoint Online Access Requests Settings with REST API/readme.md @@ -0,0 +1,25 @@ +Short Powershell script to retrieve the access requests settings using REST. + + + +In order to use the script, download, open the file and enter the admin's username and the site's url in the script: + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="t@t321.onmicrosoft.com" +$Url="https://t321.sharepoint.com/polski" + ``` +You do not need to enter the password. You will be prompted for it during script's execution. + +Sample result: + + + +You can also check out articles on Access Requests settings and how to manage them not only with REST, but also CSOM and User Interface: + +[Managing SharePoint Online Access Requests using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/31157.manage-sharepoint-online-access-requests-using-powershell.aspxv) + +[SharePoint 2013/2016: Approve or decline Access Requests using Powershell and CSOM](https://social.technet.microsoft.com/wiki/contents/articles/37401.sharepoint-online-approve-or-decline-access-requests-using-powershell-and-csom.aspx) + + From b04eaa99998e4365669fc16b52e6c3bd87ec5ce8 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 22 Jun 2023 15:57:18 +0200 Subject: [PATCH 42/97] Create readme.md --- .../readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Site Management/Access Requests/Get SharePoint Online Access Requests with REST API/readme.md diff --git a/Site Management/Access Requests/Get SharePoint Online Access Requests with REST API/readme.md b/Site Management/Access Requests/Get SharePoint Online Access Requests with REST API/readme.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/Site Management/Access Requests/Get SharePoint Online Access Requests with REST API/readme.md @@ -0,0 +1 @@ + From dbaa901863fe27cc0f1dab7a9ebad8e656aa84f2 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 22 Jun 2023 15:57:42 +0200 Subject: [PATCH 43/97] Update readme.md --- .../readme.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Site Management/Access Requests/Get SharePoint Online Access Requests with REST API/readme.md b/Site Management/Access Requests/Get SharePoint Online Access Requests with REST API/readme.md index 8b137891..7627e3d7 100644 --- a/Site Management/Access Requests/Get SharePoint Online Access Requests with REST API/readme.md +++ b/Site Management/Access Requests/Get SharePoint Online Access Requests with REST API/readme.md @@ -1 +1,28 @@ +Short Powershell script to retrieve the access requests using REST. + +In order to use the script, download, open the file and enter the admin's username and the site's url in the script: + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="t@t321.onmicrosoft.com" +$Url="https://t321.sharepoint.com/polski" + ``` +You do not need to enter the password. You will be prompted for it during script's execution. + + + +Sample result: + + + +You can also check out articles on Access Requests settings and how to manage them not only with REST, but also CSOM and User Interface: + +[Managing SharePoint Online Access Requests using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/31157.manage-sharepoint-online-access-requests-using-powershell.aspx) + +[SharePoint 2013/2016: Approve or decline Access Requests using Powershell and CSOM](https://social.technet.microsoft.com/wiki/contents/articles/37401.sharepoint-online-approve-or-decline-access-requests-using-powershell-and-csom.aspx) + + + + From 7a4f00f6d210e539a36fa1efe2530bd3694a4f83 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 26 Jun 2023 15:29:34 +0200 Subject: [PATCH 44/97] Update readme.md --- Site Management/Access Requests/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site Management/Access Requests/readme.md b/Site Management/Access Requests/readme.md index 32c0edd1..43bedac3 100644 --- a/Site Management/Access Requests/readme.md +++ b/Site Management/Access Requests/readme.md @@ -1 +1 @@ -Scripts related to managing access requests +Scripts related to managing SharePoint site access requests From effb756b7c068659766bf3d3a2f54108ab441bc6 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:19:42 +0200 Subject: [PATCH 45/97] Create readme.md --- .../readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Site Management/Access Requests/Get SharePoint Server 2013-2016 Access Requests with REST API/readme.md diff --git a/Site Management/Access Requests/Get SharePoint Server 2013-2016 Access Requests with REST API/readme.md b/Site Management/Access Requests/Get SharePoint Server 2013-2016 Access Requests with REST API/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Site Management/Access Requests/Get SharePoint Server 2013-2016 Access Requests with REST API/readme.md @@ -0,0 +1 @@ +. From 6728f9b8ccdf61920beda802eb2fb511701824b8 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 7 Aug 2023 17:07:35 +0200 Subject: [PATCH 46/97] Update readme.md --- .../SitesWithOutstandingAccessRequests/readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Site Management/Access Requests/SitesWithOutstandingAccessRequests/readme.md b/Site Management/Access Requests/SitesWithOutstandingAccessRequests/readme.md index cfe427d2..77e7f9d0 100644 --- a/Site Management/Access Requests/SitesWithOutstandingAccessRequests/readme.md +++ b/Site Management/Access Requests/SitesWithOutstandingAccessRequests/readme.md @@ -2,8 +2,7 @@ Find sites with ignored access requests, older than XXX. -How does the script work? - +### How does the script work? The script loops through your sites, verifies access requests, and compares their dates. From c973e73b0f9a87a8bb01080029b37d1b5fb7cb16 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:16:45 +0200 Subject: [PATCH 47/97] Update readme.md --- .../readme.md | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Site Management/Access Requests/Get SharePoint Server 2013-2016 Access Requests with REST API/readme.md b/Site Management/Access Requests/Get SharePoint Server 2013-2016 Access Requests with REST API/readme.md index 9c558e35..26c441f7 100644 --- a/Site Management/Access Requests/Get SharePoint Server 2013-2016 Access Requests with REST API/readme.md +++ b/Site Management/Access Requests/Get SharePoint Server 2013-2016 Access Requests with REST API/readme.md @@ -1 +1,31 @@ -. +Short Powershell script to retrieve the access requests from a SharePoint Server site using REST. + + + +In order to use the script, download, open the file and enter the admin's username and the site's url in the script: + + + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="administrator" +$Url="http://dva" + ``` +You do not need to enter the password. You will be prompted for it during script's execution. + + + +Sample result: + + + +You can also check out articles on Access Requests settings and how to manage them not only with REST, but also CSOM and User Interface: + +[Managing SharePoint Online Access Requests using Powershell](https://social.technet.microsoft.com/wiki/contents/articles/31157.manage-sharepoint-online-access-requests-using-powershell.aspx) + +[SharePoint 2013/2016: Approve or decline Access Requests using Powershell and CSOM](https://social.technet.microsoft.com/wiki/contents/articles/37401.sharepoint-online-approve-or-decline-access-requests-using-powershell-and-csom.aspx) + + + + From 192b90127fce7df7f40075fa974dfeddb7404f80 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 22 Sep 2023 09:40:02 +0200 Subject: [PATCH 48/97] Create Readme.md --- .../Views/Remove view from SharePoint Online list/Readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Lists and Libraries Management/Views/Remove view from SharePoint Online list/Readme.md diff --git a/Lists and Libraries Management/Views/Remove view from SharePoint Online list/Readme.md b/Lists and Libraries Management/Views/Remove view from SharePoint Online list/Readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Lists and Libraries Management/Views/Remove view from SharePoint Online list/Readme.md @@ -0,0 +1 @@ +. From db8383ce370f6fa4f72c9f2ab860029fb111e6da Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:49:14 +0200 Subject: [PATCH 49/97] Create readme.md --- .../Set expiration for anonymous links in SPO/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Tenant Settings/Set expiration for anonymous links in SPO/readme.md diff --git a/Tenant Settings/Set expiration for anonymous links in SPO/readme.md b/Tenant Settings/Set expiration for anonymous links in SPO/readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/Tenant Settings/Set expiration for anonymous links in SPO/readme.md @@ -0,0 +1 @@ +. From c6104cae7aab92deff73939dae883281e40e7f20 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 27 Sep 2023 20:17:14 +0200 Subject: [PATCH 50/97] Update readme.md --- .../readme.md | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Tenant Settings/Set expiration for anonymous links in SPO/readme.md b/Tenant Settings/Set expiration for anonymous links in SPO/readme.md index 9c558e35..563e99b8 100644 --- a/Tenant Settings/Set expiration for anonymous links in SPO/readme.md +++ b/Tenant Settings/Set expiration for anonymous links in SPO/readme.md @@ -1 +1,29 @@ -. +After you have enabled anonymous links for SharePoint Online tenant, you can set a requirement that the links must expire after a certain number of days. The script sets the number of days using CSOM and Powershell. + +It requires SharePoint Online SDK. + +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). + +## How to use? + +- Download and open the .ps1 file. +- Add correct libraries: + +```PowerShell +#Paths to SDK +Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` + +- Enter the correct url and admin login: + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$HowManyDaysToExpire=17 #Choose 0 if the links should not expire +``` + +- Run the script + From d72c2cfcc0ca79ade6c697e99a12ec37bcd9a13f Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 2 Oct 2023 07:56:20 +0200 Subject: [PATCH 51/97] Update README.md --- .../README.md | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/README.md b/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/README.md index 9c558e35..3b09c653 100644 --- a/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/README.md +++ b/Tenant Settings/Set default link type for SharePoint Online tenant sharing settings/README.md @@ -1 +1,30 @@ -. +Short Powershell script to modify the Sharing Link Type setting in SharePoint Admin Center via DefaultSharingLinkType property of Tenant object + +The setting can be changed also via SharePoint Admin Center: + + + +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). + +## How to use? + +- Download and open the ```.ps1``` file. +- Add correct libraries: + +```PowerShell +#Paths to SDK +Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` + +- Enter the correct url and admin login: + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$SharingLinkType="None" #None, Direct, Internal, AnonymousAccess +``` + +- Run the script From 0329e8e1b21de995652863311b53306749908550 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 3 Oct 2023 20:51:46 +0200 Subject: [PATCH 52/97] Update README.md --- .../README.md | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Tenant Settings/Set anonymous link access level for SPO tenant/README.md b/Tenant Settings/Set anonymous link access level for SPO tenant/README.md index 9c558e35..05a6237f 100644 --- a/Tenant Settings/Set anonymous link access level for SPO tenant/README.md +++ b/Tenant Settings/Set anonymous link access level for SPO tenant/README.md @@ -1 +1,32 @@ -. +After you have enabled anonymous links for SharePoint Online tenant, you can set what access level the links can give: edit or only view. The setting is global for the entire tenant. You can choose between + +**Edit** - anonymous links will allow to edit documents + +**View** - anonymous links will allow only to view documents + +**None** - users can decide about the access level on per-document basis (no global setting) + +The script is related to and more described in a Wiki article [SharePoint Online Sharing settings with CSOM](https://social.technet.microsoft.com/wiki/contents/articles/39365.sharepoint-online-sharing-settings-with-csom). + + It requires SharePoint Online SDK. + +## How to use? +- Download and open the ```.ps1``` file. +- Add correct libraries: + +```PowerShell +#Paths to SDK +Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" +``` + +- Enter the correct url and admin login: + +```PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="admin@TENANT.onmicrosoft.com" +$Url="https://TENANT-admin.sharepoint.com" +$LinkType="View" #Edit, View or None +``` +- Run the script From 3aa558029abcea8ec1c24c0cfecded8abf25339a Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 16 Dec 2023 21:39:23 +0100 Subject: [PATCH 53/97] Update ReadMe.md --- .../ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md index 8ae3f756..b1663d5a 100644 --- a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md +++ b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md @@ -26,7 +26,7 @@ $ContentTypesEnabled =$false ``` -### Please share your thoughts in the Q&A section! +### Please share your thoughts and comments! #### Wiki article with detailed code description: From e100579dca7f04207cd7e7d52c18b8c51d8601da Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 16 Dec 2023 21:44:02 +0100 Subject: [PATCH 54/97] Create ScriptUpdated2023.ps1 --- .../ScriptUpdated2023.ps1 | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Content Types/Content Types Management Setting/Set content type management setting for a single list/ScriptUpdated2023.ps1 diff --git a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ScriptUpdated2023.ps1 b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ScriptUpdated2023.ps1 new file mode 100644 index 00000000..61b00e83 --- /dev/null +++ b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ScriptUpdated2023.ps1 @@ -0,0 +1,36 @@ + +# +# Created by Arleta Wanat, 2023 +# + + +# 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" + +# Insert the credentials and the name of the site and list +$Username="trial@trialtrial123.onmicrosoft.com" +$AdminPassword="Pass" +$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" +$ListName="Tasks list" +$ContentTypesEnabled =$false # change it to true if you want to enable the setting + +# Connect + $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() + +# Update the setting + +$ll=$ctx.Web.Lists.GetByTitle($ListName) +$ll.ContentTypesEnabled = $ContentTypesEnabled +$ll.Update() + +try{ + $ctx.ExecuteQuery() + Write-Host "Done" -ForegroundColor Green + } +catch(){ + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } From 8093a01df3106e831b1389d0b5609bccfb7f6fe0 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 28 Dec 2023 10:16:54 +0100 Subject: [PATCH 55/97] Create UnsealCT.ps1 --- .../Set/Unseal a content type/UnsealCT.ps1 | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Content Types/Set/Unseal a content type/UnsealCT.ps1 diff --git a/Content Types/Set/Unseal a content type/UnsealCT.ps1 b/Content Types/Set/Unseal a content type/UnsealCT.ps1 new file mode 100644 index 00000000..4370a804 --- /dev/null +++ b/Content Types/Set/Unseal a content type/UnsealCT.ps1 @@ -0,0 +1,24 @@ + # 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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/powie1" + + +$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) +$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) +$ctx.ExecuteQuery() # not necessary, but I use it as a connection/credential check + +$ctx.Load($ctx.Web) +$ctx.Load($ctx.Web.ContentTypes) +$ctx.ExecuteQuery() + +$cc.Sealed=$false +$cc.Update($true) +$ctx.ExecuteQuery() + + +### If you get any errors, have a look at https://powershellscripts.github.io/articles/English/SharePointOnline/SharePoint%20content%20types%20in%20Powershell%20-%20known%20errors/ From df35f830c18d3f16fab3cfaf5a7c88cc1d233af0 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 28 Dec 2023 10:23:36 +0100 Subject: [PATCH 56/97] Create UnsealAllCT.ps1 --- .../UnsealAllCT.ps1 | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Content Types/Set/Unseal sealed content types in site/UnsealAllCT.ps1 diff --git a/Content Types/Set/Unseal sealed content types in site/UnsealAllCT.ps1 b/Content Types/Set/Unseal sealed content types in site/UnsealAllCT.ps1 new file mode 100644 index 00000000..a0703287 --- /dev/null +++ b/Content Types/Set/Unseal sealed content types in site/UnsealAllCT.ps1 @@ -0,0 +1,33 @@ +# 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" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/powie1" + + + +$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) +$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) +$ctx.ExecuteQuery() + +$ctx.Load($ctx.Web) +$ctx.Load($ctx.Web.ContentTypes) +$ctx.ExecuteQuery() + + +foreach($cc in $ctx.Web.ContentTypes) + { + if($cc.Sealed -eq $true) + { + Write-Host $cc.Name + $cc.Sealed=$false + $cc.Update($true) + $ctx.ExecuteQuery() + } + + } + + From cc1a8f870ee87073e0d1abcabaecc03ff6c2cec8 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 28 Dec 2023 10:24:02 +0100 Subject: [PATCH 57/97] Create readme.md --- .../readme.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Content Types/Set/Unseal sealed content types in site/readme.md diff --git a/Content Types/Set/Unseal sealed content types in site/readme.md b/Content Types/Set/Unseal sealed content types in site/readme.md new file mode 100644 index 00000000..a2588166 --- /dev/null +++ b/Content Types/Set/Unseal sealed content types in site/readme.md @@ -0,0 +1,59 @@ +What does it do? + + +The script changes the setting of .Sealed from $true to $false. + + + +It targets all site collections, which are Sealed. During its execution it displays the names of the content types it processes and errors for the read-only content types. + + + + + + + + + + + + + +It updates all dependent (child) content types as well. If you want the script not to modify the child content types, open the file and modify the following part: + + + + + +with + +PowerShell +$cc.Update($false) + + + + + + + +How to use? +Before running the script, modify the following 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" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" + +# Insert the credentials and the name of the admin site +$Username="admin@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://tenant.sharepoint.com/sites/powie1" +``` + + + + +

+Enjoy and please share feedback! From 9e0ffe87aeda5c162f7ae57a74402c68ccd66bd7 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 28 Dec 2023 10:27:09 +0100 Subject: [PATCH 58/97] Delete Content Types/Set/Unseal sealed content types in site/ModifySealed.ps1 --- .../ModifySealed.ps1 | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 Content Types/Set/Unseal sealed content types in site/ModifySealed.ps1 diff --git a/Content Types/Set/Unseal sealed content types in site/ModifySealed.ps1 b/Content Types/Set/Unseal sealed content types in site/ModifySealed.ps1 deleted file mode 100644 index de860e4a..00000000 --- a/Content Types/Set/Unseal sealed content types in site/ModifySealed.ps1 +++ /dev/null @@ -1,69 +0,0 @@ - - - - -function Get-SPOContentType -{ - - param ( - [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] - $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] - [string]$Url - ) - - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword) - $ctx.ExecuteQuery() - - $ctx.Load($ctx.Web) - - $ctx.Load($ctx.Web.ContentTypes) - $ctx.ExecuteQuery() - - - foreach($cc in $ctx.Web.ContentTypes) - { - - - - if($cc.Sealed -eq $true) - { - Write-Host $cc.Name - $cc.Sealed=$false - $cc.Update($true) - $ctx.ExecuteQuery() - } - - } - - - - - - - - } - - - - - - - - # 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" - -# Insert the credentials and the name of the admin site -$Username="admin@tenant.onmicrosoft.com" -$AdminPassword=Read-Host -Prompt "Password" -AsSecureString -$AdminUrl="https://tenant.sharepoint.com/sites/powie1" - - - - -Get-SPOContentType -Username $Username -AdminPassword $AdminPassword -Url $AdminUrl - From b00eb186a58f542fabe2168b99915354b3f3b93f Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 29 Dec 2023 10:28:32 +0100 Subject: [PATCH 59/97] Create readme.md --- .../readme.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Content Types/Set/Add column (fieldlink) to a content type/readme.md diff --git a/Content Types/Set/Add column (fieldlink) to a content type/readme.md b/Content Types/Set/Add column (fieldlink) to a content type/readme.md new file mode 100644 index 00000000..3070ea17 --- /dev/null +++ b/Content Types/Set/Add column (fieldlink) to a content type/readme.md @@ -0,0 +1,37 @@ +The script is part of the explanation on editing the content types available in the article here: + +SharePoint Online content types in Powershell: Edit. + + + + + +The example here adds an existing site column to all list content types in a particular list. The sealed content types will return an error. + + + + +The script requires SharePoint Online SDK installed. Before running the script, enter the information: + + + +```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" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Publishing.dll" +# Insert the credentials and the name of the admin site +$Username="t@trial345.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$AdminUrl="https://trial345.sharepoint.com/sites/teamsitewithlists" +$ListTitle="opoo" +$SiteColumn="IMEPos" +``` + + + + + + +

+Enjoy and please share feedback! From 2a1465fb290ba16160c13c7b517a513628a7386d Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 16 Jan 2024 23:31:33 +0100 Subject: [PATCH 60/97] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 80aec137..40096f5f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SharePointOnline-ScriptSamples -Over 200 SharePoint Online scripts +Over 260 SharePoint Online scripts * fixing issues * generating reports * extra settings not available via UI From c9076658c8727aa65b86e8b5357c0d18dd57e51b Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:22:10 +0100 Subject: [PATCH 61/97] Update README.md --- .../README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lists and Libraries Management/Modern or Classic/Verify which lists have the new UI using Powershell and REST/README.md b/Lists and Libraries Management/Modern or Classic/Verify which lists have the new UI using Powershell and REST/README.md index b32385d9..5bb45fa8 100644 --- a/Lists and Libraries Management/Modern or Classic/Verify which lists have the new UI using Powershell and REST/README.md +++ b/Lists and Libraries Management/Modern or Classic/Verify which lists have the new UI using Powershell and REST/README.md @@ -1,4 +1,4 @@ -Short Powershell that checks which SharePoint Online list has what experience setting. +Short Powershell script that checks which SharePoint Online list has what experience setting. From dacb2d710cdca010f58fce3651ea768264df227a Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Tue, 18 Jun 2024 16:09:21 +0200 Subject: [PATCH 62/97] Delete Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/description.md --- .../description.md | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/description.md diff --git a/Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/description.md b/Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/description.md deleted file mode 100644 index 1c594634..00000000 --- a/Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/description.md +++ /dev/null @@ -1,31 +0,0 @@ -A short script for SharePoint Online tenants to retrieve all terms from the termstore. - -The script iterates through Groups, TermSets and Terms, loading properties of each and displaying them. - -Before running the script, open the file and enter your tenant's data: - -```PowerShell -#Enter the data -$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString -$username="t@trial456.onmicrosoft.com" -$Url="https://trial456-admin.sharepoint.com" - ``` - - -The script requires SharePoint Online SDK. Download and install the libraries and refer them in the script. In the most common scenario all that is required is changing **15\ISAPI** value to **16\ISAPI**: - - - -```PowerShell - #Paths to SDK -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" -Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll" - ``` - - - -Expected results: - - - From 71d42d78224571ddd34d530b30d8182abde8b8eb Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:36:36 +0200 Subject: [PATCH 63/97] Create UsingPnP.ps1 --- .../UsingPnP.ps1 | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/UsingPnP.ps1 diff --git a/Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/UsingPnP.ps1 b/Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/UsingPnP.ps1 new file mode 100644 index 00000000..a1a147d5 --- /dev/null +++ b/Managed Metadata/Pull all groups, termsets, terms from your default SharePoint Online termstore/UsingPnP.ps1 @@ -0,0 +1,26 @@ + +Connect-PNPOnline https://TENANT-admin.sharepoint.com -Credentials $myPsCred +$Context = Get-PnPContext + +$Groups = Get-PNPTermGroup + +Foreach($group in $Groups){ + + $termsets = Get-PnPTermset -TermGroup $group + + Write-Output "$($Group.Name) group with $($termsets.Count) termsets" + + Foreach($termset in $termsets){ + + $termset.Name + $terms = $termset.Terms + $Context.Load($terms) # You cannot get all terms using Get-PnPTerm cmdlet + $Context.ExecuteQuery() + + + foreach ($term in $terms){ + + Write-Output "$($term.Name)" + } + } +} From 19215697bdf4bbfa588bf3cc2f120f70f715a579 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Mon, 15 Jul 2024 16:53:46 +0200 Subject: [PATCH 64/97] Create AllowContentTypeManagementUsingPnPInvokeQuery.ps1 --- ...ntentTypeManagementUsingPnPInvokeQuery.ps1 | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Content Types/Content Types Management Setting/Allow content type management for all lists in a site/AllowContentTypeManagementUsingPnPInvokeQuery.ps1 diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/AllowContentTypeManagementUsingPnPInvokeQuery.ps1 b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/AllowContentTypeManagementUsingPnPInvokeQuery.ps1 new file mode 100644 index 00000000..4255fa8d --- /dev/null +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/AllowContentTypeManagementUsingPnPInvokeQuery.ps1 @@ -0,0 +1,42 @@ +# Ensure you have the SharePoint PnP PowerShell module installed +# Install-Module SharePointPnPPowerShellOnline -Scope CurrentUser + +function Set-PnPListsContentTypesEnabled { + param ( + [Parameter(Mandatory = $true)] + [string]$Username, + [Parameter(Mandatory = $true)] + [string]$Password, + [Parameter(Mandatory = $true)] + [string]$Url, + [Parameter(Mandatory = $true)] + [bool]$ContentTypesEnabled + ) + + # Connect to SharePoint Online + Connect-PnPOnline -Url $Url -Credentials (Get-Credential -UserName $Username -Message "Enter your password") + + # Get all lists from the current web + $Lists = Get-PnPList + + # Loop through each list and update ContentTypesEnabled + foreach ($List in $Lists) { + $List.ContentTypesEnabled = $ContentTypesEnabled + $List.Update() + Invoke-PnPQuery + + Write-Host "$($List.Title) - Done" -ForegroundColor Green + } + + # Disconnect from SharePoint Online + Disconnect-PnPOnline +} + +# Replace these variables with your actual credentials and settings +$Username = "trial@trialtrial123.onmicrosoft.com" +$Password = ConvertTo-SecureString "Pass" -AsPlainText -Force +$Url = "https://trialtrial123.sharepoint.com/sites/teamsitewithlists" +$ContentTypesEnabled = $true + +# Call the function to set ContentTypesEnabled for lists +Set-PnPListsContentTypesEnabled -Username $Username -Password $Password -Url $Url -ContentTypesEnabled $ContentTypesEnabled From eb78c75a707d0732af7bd9bff0cb969a5d205d20 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:33:16 +0200 Subject: [PATCH 65/97] Create countfilesrecursively.ps1 --- .../countfilesrecursively.ps1 | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 File Management/CountFiles/InSpecificFolder/countfilesrecursively.ps1 diff --git a/File Management/CountFiles/InSpecificFolder/countfilesrecursively.ps1 b/File Management/CountFiles/InSpecificFolder/countfilesrecursively.ps1 new file mode 100644 index 00000000..b183a4c4 --- /dev/null +++ b/File Management/CountFiles/InSpecificFolder/countfilesrecursively.ps1 @@ -0,0 +1,37 @@ +### Count all files recursively inside a specific folder + + +Install-Module -Name PnP.PowerShell -Force -AllowClobber +Import-Module PnP.PowerShell + + +Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive + + +# Define the folder URL relative to the document library +$folderUrl = "/sites/yoursite/Shared Documents/YourFolder" + +# Get the folder +$folder = Get-PnPFolder -Url $folderUrl -Includes Files, Folders + +# Initialize file count +$fileCount = 0 + +# Function to count files recursively +function Count-Files($folder) { + param ($folder) + + # Count files in the current folder + $fileCount += $folder.Files.Count + + # Recurse into each subfolder + foreach ($subFolder in $folder.Folders) { + Count-Files -folder $subFolder + } +} + +# Start counting files from the root folder +Count-Files -folder $folder + +# Output the total count +Write-Host "Total files: $fileCount" From 73cbbf3dda3c52c5206f3800170e61a600a2a302 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 10 Aug 2024 23:07:52 +0200 Subject: [PATCH 66/97] Create countfilesrecursivelyinalist.ps1 --- .../CountFiles/InAList/countfilesrecursivelyinalist.ps1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 File Management/CountFiles/InAList/countfilesrecursivelyinalist.ps1 diff --git a/File Management/CountFiles/InAList/countfilesrecursivelyinalist.ps1 b/File Management/CountFiles/InAList/countfilesrecursivelyinalist.ps1 new file mode 100644 index 00000000..f3229c5b --- /dev/null +++ b/File Management/CountFiles/InAList/countfilesrecursivelyinalist.ps1 @@ -0,0 +1 @@ +.. From bd180250c43aae222de632e3457b9002c919ba33 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 10 Aug 2024 23:09:13 +0200 Subject: [PATCH 67/97] Update and rename countfilesrecursivelyinalist.ps1 to countfilesrecursivelyinalibrary.ps1 --- .../CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 | 6 ++++++ .../CountFiles/InAList/countfilesrecursivelyinalist.ps1 | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 delete mode 100644 File Management/CountFiles/InAList/countfilesrecursivelyinalist.ps1 diff --git a/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 b/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 new file mode 100644 index 00000000..69ce384d --- /dev/null +++ b/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 @@ -0,0 +1,6 @@ +Install-Module -Name PnP.PowerShell -Force -AllowClobber +Import-Module PnP.PowerShell + +Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive + + diff --git a/File Management/CountFiles/InAList/countfilesrecursivelyinalist.ps1 b/File Management/CountFiles/InAList/countfilesrecursivelyinalist.ps1 deleted file mode 100644 index f3229c5b..00000000 --- a/File Management/CountFiles/InAList/countfilesrecursivelyinalist.ps1 +++ /dev/null @@ -1 +0,0 @@ -.. From 882f58dd350d5a06e85faebea1265a9f865d76a1 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 10 Aug 2024 23:09:46 +0200 Subject: [PATCH 68/97] Update countfilesrecursivelyinalibrary.ps1 --- .../countfilesrecursivelyinalibrary.ps1 | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 b/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 index 69ce384d..3929d597 100644 --- a/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 +++ b/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 @@ -4,3 +4,33 @@ Import-Module PnP.PowerShell Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive +# Define the document library name +$libraryName = "Documents" # Change this to your document library name + +# Get the root folder of the document library +$rootFolder = Get-PnPList -Identity $libraryName | Get-PnPProperty -Property RootFolder + +# Initialize file count +$fileCount = 0 + +# Function to count files recursively in a folder +function Count-Files($folder) { + param ($folder) + + # Count files in the current folder + $fileCount += ($folder | Get-PnPFolderItem -ItemType File).Count + + # Get all subfolders and recurse into each one + $subFolders = Get-PnPFolderItem -FolderSiteRelativeUrl $folder.ServerRelativeUrl -ItemType Folder + foreach ($subFolder in $subFolders) { + Count-Files -folder $subFolder + } +} + +# Start counting files from the root folder of the document library +Count-Files -folder $rootFolder + +# Output the total count +Write-Host "Total files in the document library '$libraryName': $fileCount" + + From 8e8e3a51e2806dfbda43a82b52e98267d48269fc Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 10 Aug 2024 23:10:46 +0200 Subject: [PATCH 69/97] Update countfilesrecursivelyinalibrary.ps1 --- .../CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 b/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 index 3929d597..8d12625a 100644 --- a/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 +++ b/File Management/CountFiles/InAList/countfilesrecursivelyinalibrary.ps1 @@ -1,3 +1,5 @@ +# count files recursively in the entire library + Install-Module -Name PnP.PowerShell -Force -AllowClobber Import-Module PnP.PowerShell From 6db08f642b7594ca1a086537c727853fdf1c364b Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 17 Aug 2024 23:45:32 +0200 Subject: [PATCH 70/97] Create InFolder.ps1 --- File Management/CountFiles/WithUniquePermissions/InFolder.ps1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 File Management/CountFiles/WithUniquePermissions/InFolder.ps1 diff --git a/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 b/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 @@ -0,0 +1 @@ +. From 4a9b569f0a793c5597dc4951a8dffe09dac714be Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 17 Aug 2024 23:46:36 +0200 Subject: [PATCH 71/97] Create InLibrary.ps1 --- File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 diff --git a/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 b/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 new file mode 100644 index 00000000..f3229c5b --- /dev/null +++ b/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 @@ -0,0 +1 @@ +.. From a3d88aa467be687b8c0bcace819d565178be47ce Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 18 Aug 2024 17:47:33 +0200 Subject: [PATCH 72/97] Update InFolder.ps1 --- .../WithUniquePermissions/InFolder.ps1 | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 b/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 index 9c558e35..922c514c 100644 --- a/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 +++ b/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 @@ -1 +1,24 @@ -. + +# Connect to SharePoint Online +Connect-PnPOnline -Url "https://yoursite.sharepoint.com/sites/yoursite" -Interactive + +# Define the folder URL relative to the document library +$folderUrl = "/sites/yoursite/Shared Documents/YourFolder" +$list = "Shared Documents" + +# Initialize the count for items with unique permissions +$fileCountWithUniquePermissions = 0; + +# Get the folder +$folder = Get-PnPFolder -Url $folderUrl -Includes Files, Folders + +foreach ($file in $folder.Files) { + $fileItem = Get-PnPListItem -List $list -Id $file.ListItemAllFields.Id + if ($fileItem.HasUniqueRoleAssignments) { + $fileCountWithUniquePermissions++ + } +} + + +# Output the total count +Write-Host "Total files: $fileCountWithUniquePermissions" From c49b52b915380e952abdb6fcb5fb11c1faebf614 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 18 Aug 2024 17:48:16 +0200 Subject: [PATCH 73/97] Update InLibrary.ps1 --- .../WithUniquePermissions/InLibrary.ps1 | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 b/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 index f3229c5b..65c8ab81 100644 --- a/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 +++ b/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 @@ -1 +1,23 @@ -.. + + + +# Define the list name +$listName = "YourListName" + +# Get all list items +$items = Get-PnPListItem -List $listName -PageSize 5000 + +# Initialize the count for items with unique permissions +$uniquePermissionCount = 0 + +# Iterate through each item to check for unique permissions +foreach ($item in $items) { + # Check if the item has unique permissions + if ($item.HasUniqueRoleAssignments) { + # Increment the count if unique permissions are found + $uniquePermissionCount++ + } +} + +# Output the total count of items with unique permissions +Write-Host "Total items with unique permissions: $uniquePermissionCount" From 531a3f65fc7ecb99a76215752bad30db85ccfe8a Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 18 Aug 2024 17:48:45 +0200 Subject: [PATCH 74/97] Update InLibrary.ps1 --- File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 b/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 index 65c8ab81..93e642ff 100644 --- a/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 +++ b/File Management/CountFiles/WithUniquePermissions/InLibrary.ps1 @@ -1,5 +1,7 @@ +# Connect to SharePoint Online +Connect-PnPOnline -Url "https://yoursite.sharepoint.com/sites/yoursite" -Interactive # Define the list name $listName = "YourListName" From 6c2fa8914a9265097451500e560ec389e75af698 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:40:53 +0200 Subject: [PATCH 75/97] Create Readme.md --- File Management/CountFiles/Readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 File Management/CountFiles/Readme.md diff --git a/File Management/CountFiles/Readme.md b/File Management/CountFiles/Readme.md new file mode 100644 index 00000000..9c558e35 --- /dev/null +++ b/File Management/CountFiles/Readme.md @@ -0,0 +1 @@ +. From 2d07738df0d8d6051cb0a5a758e6bca9bb49d4c9 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:41:30 +0200 Subject: [PATCH 76/97] Update Readme.md --- File Management/CountFiles/Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/File Management/CountFiles/Readme.md b/File Management/CountFiles/Readme.md index 9c558e35..8c5c9e67 100644 --- a/File Management/CountFiles/Readme.md +++ b/File Management/CountFiles/Readme.md @@ -1 +1 @@ -. +Short PnP scripts that count files. From b5858b30c5e6636eaba5de35815b01de0b5507d9 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 25 Aug 2024 20:11:31 +0200 Subject: [PATCH 77/97] Create countfilesinRootFolder.ps1 --- .../InAList/countfilesinRootFolder.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 File Management/CountFiles/InAList/countfilesinRootFolder.ps1 diff --git a/File Management/CountFiles/InAList/countfilesinRootFolder.ps1 b/File Management/CountFiles/InAList/countfilesinRootFolder.ps1 new file mode 100644 index 00000000..66656817 --- /dev/null +++ b/File Management/CountFiles/InAList/countfilesinRootFolder.ps1 @@ -0,0 +1,17 @@ +# count files in the entire library (not recursive!) + +Install-Module -Name PnP.PowerShell -Force -AllowClobber +Import-Module PnP.PowerShell + +Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive + +# Define the document library name +$libraryName = "Documents" # Change this to your document library name + +# Get the root folder of the document library +$Folder = Get-PnPList -Identity $libraryName | Get-PnPProperty -Property RootFolder + +$items = Get-PnPFolderItem -FolderSiteRelativeUrl $folder.ServerRelativeUrl + +# Output the total count +Write-Host "Total files in the document library '$libraryName': $($items.Count)" From ab03973a188490b6a26a1a7bf5bebf4c113ec77b Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 25 Aug 2024 20:54:36 +0200 Subject: [PATCH 78/97] Update InFolder.ps1 --- File Management/CountFiles/WithUniquePermissions/InFolder.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 b/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 index 922c514c..ac8de630 100644 --- a/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 +++ b/File Management/CountFiles/WithUniquePermissions/InFolder.ps1 @@ -1,3 +1,6 @@ +# Counts files with unique permissions in a folder + + # Connect to SharePoint Online Connect-PnPOnline -Url "https://yoursite.sharepoint.com/sites/yoursite" -Interactive From 796177b25e2c847707a2e060b981f2b5ac5b7e15 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Wed, 20 Nov 2024 22:42:56 +0100 Subject: [PATCH 79/97] Create compare2tenants.ps1 --- .../Compare2tenants/compare2tenants.ps1 | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Tenant Settings/Compare2tenants/compare2tenants.ps1 diff --git a/Tenant Settings/Compare2tenants/compare2tenants.ps1 b/Tenant Settings/Compare2tenants/compare2tenants.ps1 new file mode 100644 index 00000000..d568aa09 --- /dev/null +++ b/Tenant Settings/Compare2tenants/compare2tenants.ps1 @@ -0,0 +1,61 @@ +# Define a function to connect to a tenant and get properties +function Get-TenantProperties { + param ( + [string]$AdminUrl + ) + + Write-Host "Connecting to $AdminUrl..." -ForegroundColor Cyan + Connect-SPOService -Url $AdminUrl + $tenantProperties = Get-SPOTenant | Select-Object * + Disconnect-SPOService + return $tenantProperties +} + +# Define a function to compare two objects +function Compare-TenantProperties { + param ( + [PSCustomObject]$Tenant1, + [PSCustomObject]$Tenant2 + ) + + $comparison = @() + foreach ($property in $Tenant1.PSObject.Properties) { + $propertyName = $property.Name + $value1 = $Tenant1.$propertyName + $value2 = $Tenant2.$propertyName + + $comparison += [PSCustomObject]@{ + PropertyName = $propertyName + Tenant1Value = $value1 + Tenant2Value = $value2 + IsDifferent = $value1 -ne $value2 + } + } + return $comparison +} + +# Enter the admin URLs for the two tenants +$Tenant1AdminUrl = "https://tenant1-admin.sharepoint.com" +$Tenant2AdminUrl = "https://tenant2-admin.sharepoint.com" + +# Get properties from both tenants +$Tenant1Properties = Get-TenantProperties -AdminUrl $Tenant1AdminUrl +$Tenant2Properties = Get-TenantProperties -AdminUrl $Tenant2AdminUrl + +# Compare the properties +$ComparisonResults = Compare-TenantProperties -Tenant1 $Tenant1Properties -Tenant2 $Tenant2Properties + +# Filter only the differences +$Differences = $ComparisonResults | Where-Object { $_.IsDifferent -eq $true } + +# Output to console +Write-Host "Comparison complete." -ForegroundColor Green + +# Export all settings compared +$ComparisonResults | Format-Table -AutoSize +$ComparisonResults | Export-Csv -Path "TenantComparison_Full.csv" -NoTypeInformation -Encoding UTF8 +Write-Host "Full comparison exported to TenantComparison_Full.csv" -ForegroundColor Cyan + +# Export only differences +$Differences | Export-Csv -Path "TenantComparison_Differences.csv" -NoTypeInformation -Encoding UTF8 +Write-Host "Differences exported to TenantComparison_Differences.csv" -ForegroundColor Cyan From 4def7100864e66415f85b8c2d2aa2d7d18a82e35 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:44:18 +0100 Subject: [PATCH 80/97] Update compare2tenants.ps1 --- Tenant Settings/Compare2tenants/compare2tenants.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tenant Settings/Compare2tenants/compare2tenants.ps1 b/Tenant Settings/Compare2tenants/compare2tenants.ps1 index d568aa09..c852413f 100644 --- a/Tenant Settings/Compare2tenants/compare2tenants.ps1 +++ b/Tenant Settings/Compare2tenants/compare2tenants.ps1 @@ -1,3 +1,6 @@ +# Written 2024 by Arleta Wanat +# The script looks for differences + # Define a function to connect to a tenant and get properties function Get-TenantProperties { param ( From 320e7924f3628e5f5a4ceb2314fa84e7a5855ad2 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:45:05 +0100 Subject: [PATCH 81/97] Update compare2tenants.ps1 --- Tenant Settings/Compare2tenants/compare2tenants.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tenant Settings/Compare2tenants/compare2tenants.ps1 b/Tenant Settings/Compare2tenants/compare2tenants.ps1 index c852413f..417706f9 100644 --- a/Tenant Settings/Compare2tenants/compare2tenants.ps1 +++ b/Tenant Settings/Compare2tenants/compare2tenants.ps1 @@ -1,5 +1,6 @@ # Written 2024 by Arleta Wanat -# The script looks for differences +# The script looks for differences between SharePoint settings in 2 Microsoft 365 tenants. It displays the differences and on the screen and generates 2 files: + # Define a function to connect to a tenant and get properties function Get-TenantProperties { From 343232d15a6105babc62f45409e54ab9a15b8a21 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:45:53 +0100 Subject: [PATCH 82/97] Update compare2tenants.ps1 --- Tenant Settings/Compare2tenants/compare2tenants.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tenant Settings/Compare2tenants/compare2tenants.ps1 b/Tenant Settings/Compare2tenants/compare2tenants.ps1 index 417706f9..a022a034 100644 --- a/Tenant Settings/Compare2tenants/compare2tenants.ps1 +++ b/Tenant Settings/Compare2tenants/compare2tenants.ps1 @@ -1,6 +1,6 @@ # Written 2024 by Arleta Wanat # The script looks for differences between SharePoint settings in 2 Microsoft 365 tenants. It displays the differences and on the screen and generates 2 files: - +# One CSV only with differences, and one CSV with all the compared settings # Define a function to connect to a tenant and get properties function Get-TenantProperties { From dbc0e0d961bfe70cefed8c5fe13a23ea6e1c14a7 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:48:28 +0100 Subject: [PATCH 83/97] Update compare2tenants.ps1 --- Tenant Settings/Compare2tenants/compare2tenants.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Tenant Settings/Compare2tenants/compare2tenants.ps1 b/Tenant Settings/Compare2tenants/compare2tenants.ps1 index a022a034..273fb6a2 100644 --- a/Tenant Settings/Compare2tenants/compare2tenants.ps1 +++ b/Tenant Settings/Compare2tenants/compare2tenants.ps1 @@ -1,6 +1,7 @@ # Written 2024 by Arleta Wanat # The script looks for differences between SharePoint settings in 2 Microsoft 365 tenants. It displays the differences and on the screen and generates 2 files: # One CSV only with differences, and one CSV with all the compared settings +# For more info go to https://powershellscripts.github.io/articles/en/spo/comparetenant # Define a function to connect to a tenant and get properties function Get-TenantProperties { From 37a4bdfe7f9c37e5d249c02fec17002636af619b Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:21:25 +0100 Subject: [PATCH 84/97] Rename compare2tenants.ps1 to compare2tenantsSPOManagementShell.ps1 --- ...{compare2tenants.ps1 => compare2tenantsSPOManagementShell.ps1} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Tenant Settings/Compare2tenants/{compare2tenants.ps1 => compare2tenantsSPOManagementShell.ps1} (100%) diff --git a/Tenant Settings/Compare2tenants/compare2tenants.ps1 b/Tenant Settings/Compare2tenants/compare2tenantsSPOManagementShell.ps1 similarity index 100% rename from Tenant Settings/Compare2tenants/compare2tenants.ps1 rename to Tenant Settings/Compare2tenants/compare2tenantsSPOManagementShell.ps1 From 36f7e135800bb548e102d1987b75c0fd1a6a99a3 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:22:02 +0100 Subject: [PATCH 85/97] Create compare2tenantPNPPowershell.ps1 --- .../compare2tenantPNPPowershell.ps1 | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Tenant Settings/Compare2tenants/compare2tenantPNPPowershell.ps1 diff --git a/Tenant Settings/Compare2tenants/compare2tenantPNPPowershell.ps1 b/Tenant Settings/Compare2tenants/compare2tenantPNPPowershell.ps1 new file mode 100644 index 00000000..575d7706 --- /dev/null +++ b/Tenant Settings/Compare2tenants/compare2tenantPNPPowershell.ps1 @@ -0,0 +1,59 @@ +# Ensure PnP PowerShell module is installed +# Install-Module -Name PnP.PowerShell -Force + +# Connect to the first tenant +$Tenant1Url = "https://tenant1-admin.sharepoint.com" +$Tenant2Url = "https://tenant2-admin.sharepoint.com" + +Write-Host "Connecting to Tenant 1: $Tenant1Url" -ForegroundColor Cyan +Connect-PnPOnline -Url $Tenant1Url -Interactive +$Tenant1Properties = Get-PnPTenant | Select-Object -Property * + +# Connect to the second tenant +Write-Host "Connecting to Tenant 2: $Tenant2Url" -ForegroundColor Cyan +Connect-PnPOnline -Url $Tenant2Url -Interactive +$Tenant2Properties = Get-PnPTenant | Select-Object -Property * + +# Compare the tenant properties +Write-Host "Comparing properties..." -ForegroundColor Yellow +$Comparison = @() +$AllProperties = $Tenant1Properties.PSObject.Properties.Name + +foreach ($Property in $AllProperties) { + $Value1 = $Tenant1Properties.$Property + $Value2 = $Tenant2Properties.$Property + + if ($Value1 -ne $Value2) { + $Comparison += [PSCustomObject]@{ + PropertyName = $Property + Tenant1Value = $Value1 + Tenant2Value = $Value2 + } + } +} + +# Output the differences +if ($Comparison.Count -gt 0) { + Write-Host "Differences found:" -ForegroundColor Green + $Comparison | Format-Table -AutoSize + + # Export differences to CSV + $Comparison | Export-Csv -Path "TenantDifferences.csv" -NoTypeInformation + Write-Host "Differences exported to TenantDifferences.csv" -ForegroundColor Green +} else { + Write-Host "No differences found between the two tenants." -ForegroundColor Green +} + +# Output all properties for full comparison +$FullComparison = @() +foreach ($Property in $AllProperties) { + $FullComparison += [PSCustomObject]@{ + PropertyName = $Property + Tenant1Value = $Tenant1Properties.$Property + Tenant2Value = $Tenant2Properties.$Property + } +} + +# Export full comparison to CSV +$FullComparison | Export-Csv -Path "FullTenantComparison.csv" -NoTypeInformation +Write-Host "Full comparison exported to FullTenantComparison.csv" -ForegroundColor Green From 3570ce9f572ec0dcf9d747135bacd1c5254b6e8a Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:22:50 +0100 Subject: [PATCH 86/97] Create compare2tenantsCSOM.ps1 --- .../Compare2tenants/compare2tenantsCSOM.ps1 | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 diff --git a/Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 b/Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 new file mode 100644 index 00000000..c88a0be9 --- /dev/null +++ b/Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 @@ -0,0 +1,90 @@ +# Load required assemblies +Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" + +# Function to get tenant properties +function Get-TenantProperties { + param ( + [string]$AdminUrl, + [string]$Username, + [string]$Password + ) + + $securePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force + $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $securePassword) + + $context = New-Object Microsoft.SharePoint.Client.ClientContext($AdminUrl) + $context.Credentials = $credentials + + # Load tenant properties + $tenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($context) + $context.Load($tenant) + $context.ExecuteQuery() + + # Extract and return tenant properties + return $tenant | Get-Member -MemberType Property | ForEach-Object { + [PSCustomObject]@{ + PropertyName = $_.Name + PropertyValue = $tenant.($_.Name) + } + } +} + +# Connect to the first tenant +$Tenant1AdminUrl = "https://tenant1-admin.sharepoint.com" +$Tenant1Username = "admin1@tenant1.onmicrosoft.com" +$Tenant1Password = "YourPassword1" + +Write-Host "Retrieving properties from Tenant 1: $Tenant1AdminUrl" -ForegroundColor Cyan +$Tenant1Properties = Get-TenantProperties -AdminUrl $Tenant1AdminUrl -Username $Tenant1Username -Password $Tenant1Password + +# Connect to the second tenant +$Tenant2AdminUrl = "https://tenant2-admin.sharepoint.com" +$Tenant2Username = "admin2@tenant2.onmicrosoft.com" +$Tenant2Password = "YourPassword2" + +Write-Host "Retrieving properties from Tenant 2: $Tenant2AdminUrl" -ForegroundColor Cyan +$Tenant2Properties = Get-TenantProperties -AdminUrl $Tenant2AdminUrl -Username $Tenant2Username -Password $Tenant2Password + +# Compare tenant properties +Write-Host "Comparing properties..." -ForegroundColor Yellow +$Comparison = @() + +foreach ($Property in $Tenant1Properties) { + $Tenant2Value = ($Tenant2Properties | Where-Object { $_.PropertyName -eq $Property.PropertyName }).PropertyValue + + if ($Property.PropertyValue -ne $Tenant2Value) { + $Comparison += [PSCustomObject]@{ + PropertyName = $Property.PropertyName + Tenant1Value = $Property.PropertyValue + Tenant2Value = $Tenant2Value + } + } +} + +# Output the differences +if ($Comparison.Count -gt 0) { + Write-Host "Differences found:" -ForegroundColor Green + $Comparison | Format-Table -AutoSize + + # Export differences to CSV + $Comparison | Export-Csv -Path "TenantDifferences.csv" -NoTypeInformation + Write-Host "Differences exported to TenantDifferences.csv" -ForegroundColor Green +} else { + Write-Host "No differences found between the two tenants." -ForegroundColor Green +} + +# Output all properties for full comparison +$FullComparison = $Tenant1Properties | ForEach-Object { + $Tenant2Value = ($Tenant2Properties | Where-Object { $_.PropertyName -eq $_.PropertyName }).PropertyValue + + [PSCustomObject]@{ + PropertyName = $_.PropertyName + Tenant1Value = $_.PropertyValue + Tenant2Value = $Tenant2Value + } +} + +# Export full comparison to CSV +$FullComparison | Export-Csv -Path "FullTenantComparison.csv" -NoTypeInformation +Write-Host "Full comparison exported to FullTenantComparison.csv" -ForegroundColor Green From 2cdc90dcec9a58b08dd56bd55f55265fc9f5d4a2 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:24:00 +0100 Subject: [PATCH 87/97] Update and rename compare2tenantPNPPowershell.ps1 to compare2tenantsPNPPowershell.ps1 --- ...ntPNPPowershell.ps1 => compare2tenantsPNPPowershell.ps1} | 6 ++++++ 1 file changed, 6 insertions(+) rename Tenant Settings/Compare2tenants/{compare2tenantPNPPowershell.ps1 => compare2tenantsPNPPowershell.ps1} (85%) diff --git a/Tenant Settings/Compare2tenants/compare2tenantPNPPowershell.ps1 b/Tenant Settings/Compare2tenants/compare2tenantsPNPPowershell.ps1 similarity index 85% rename from Tenant Settings/Compare2tenants/compare2tenantPNPPowershell.ps1 rename to Tenant Settings/Compare2tenants/compare2tenantsPNPPowershell.ps1 index 575d7706..e9fc09f9 100644 --- a/Tenant Settings/Compare2tenants/compare2tenantPNPPowershell.ps1 +++ b/Tenant Settings/Compare2tenants/compare2tenantsPNPPowershell.ps1 @@ -1,3 +1,9 @@ +# Written 2024 by Arleta Wanat +# The script looks for differences between SharePoint settings in 2 Microsoft 365 tenants. It displays the differences and on the screen and generates 2 files: +# One CSV only with differences, and one CSV with all the compared settings +# For more info go to https://powershellscripts.github.io/articles/en/spo/comparetenants + + # Ensure PnP PowerShell module is installed # Install-Module -Name PnP.PowerShell -Force From d55bd5a44de156e5f8c75a07fc65d6f5da85ac86 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:24:21 +0100 Subject: [PATCH 88/97] Update compare2tenantsCSOM.ps1 --- Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 b/Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 index c88a0be9..042d715a 100644 --- a/Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 +++ b/Tenant Settings/Compare2tenants/compare2tenantsCSOM.ps1 @@ -1,3 +1,9 @@ +# Written 2024 by Arleta Wanat +# The script looks for differences between SharePoint settings in 2 Microsoft 365 tenants. It displays the differences and on the screen and generates 2 files: +# One CSV only with differences, and one CSV with all the compared settings +# For more info go to https://powershellscripts.github.io/articles/en/spo/comparetenants + + # Load required assemblies Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" From e9daef27656a433b578fe2e105c01aa4126e13db Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:28:19 +0100 Subject: [PATCH 89/97] Update and rename MinorVersioning.ps1 to MinorVersioningCSOM.ps1 --- .../{MinorVersioning.ps1 => MinorVersioningCSOM.ps1} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Versioning/Enable minor versions for all lists/{MinorVersioning.ps1 => MinorVersioningCSOM.ps1} (100%) diff --git a/Versioning/Enable minor versions for all lists/MinorVersioning.ps1 b/Versioning/Enable minor versions for all lists/MinorVersioningCSOM.ps1 similarity index 100% rename from Versioning/Enable minor versions for all lists/MinorVersioning.ps1 rename to Versioning/Enable minor versions for all lists/MinorVersioningCSOM.ps1 From 0084aeda64f935969615510214eb1769d444277f Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:30:54 +0100 Subject: [PATCH 90/97] Create MinorVersioningPnP.ps1 --- .../MinorVersioningPnP.ps1 | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Versioning/Enable minor versions for all lists/MinorVersioningPnP.ps1 diff --git a/Versioning/Enable minor versions for all lists/MinorVersioningPnP.ps1 b/Versioning/Enable minor versions for all lists/MinorVersioningPnP.ps1 new file mode 100644 index 00000000..197f8689 --- /dev/null +++ b/Versioning/Enable minor versions for all lists/MinorVersioningPnP.ps1 @@ -0,0 +1,20 @@ +# Written by Arleta Wanat 2024 + +# Connect to the SharePoint Online site +Connect-PnPOnline -Url "https://.sharepoint.com/sites/" -UseWebLogin + +# Retrieve all lists in the site collection +$lists = Get-PnPList + +# Iterate through each list to enable minor versioning +foreach ($list in $lists) { + # Check if the list allows versioning + if ($list.BaseType -eq "GenericList" -or $list.BaseType -eq "DocumentLibrary") { + Write-Host "Processing list: $($list.Title)" + Set-PnPList -Identity $list.Title -EnableVersioning $true -EnableMinorVersions $true -MinorVersionLimit 10 + Write-Host "Minor versioning enabled for: $($list.Title)" + } +} + +# Disconnect from the site +Disconnect-PnPOnline From 4d8e4a4fee8d3da3eec310cfa0aa32f0d0fd9d54 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:31:33 +0100 Subject: [PATCH 91/97] Update and rename Versioning.ps1 to VersioningCSOM.ps1 --- .../{Versioning.ps1 => VersioningCSOM.ps1} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Versioning/Enable versioning for all SharePoint Online lists/{Versioning.ps1 => VersioningCSOM.ps1} (100%) diff --git a/Versioning/Enable versioning for all SharePoint Online lists/Versioning.ps1 b/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 similarity index 100% rename from Versioning/Enable versioning for all SharePoint Online lists/Versioning.ps1 rename to Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 From 72f449f28db97868b6d41126f46eedec258e8652 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:31:54 +0100 Subject: [PATCH 92/97] Update VersioningCSOM.ps1 --- .../VersioningCSOM.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 b/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 index 68f646e4..84917e55 100644 --- a/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 +++ b/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 @@ -1,4 +1,6 @@ -function getall($urelek){ +# Created by Arleta Wanat, 2014 + + function getall($urelek){ $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $ctx.Load($ctx.Web.Lists) From 087370dd7ff52f3d7e25b89be00230d738a4b4c6 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:37:08 +0100 Subject: [PATCH 93/97] Create VersioningPnP.ps1 --- .../VersioningPnP.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Versioning/Enable versioning for all SharePoint Online lists/VersioningPnP.ps1 diff --git a/Versioning/Enable versioning for all SharePoint Online lists/VersioningPnP.ps1 b/Versioning/Enable versioning for all SharePoint Online lists/VersioningPnP.ps1 new file mode 100644 index 00000000..8c29b37b --- /dev/null +++ b/Versioning/Enable versioning for all SharePoint Online lists/VersioningPnP.ps1 @@ -0,0 +1,18 @@ +Written by Arleta Wanat, 2024 + +# Connect to the SharePoint Online site +Connect-PnPOnline -Url "https://.sharepoint.com/sites/" -Credential (Get-Credential) + +# Get all lists in the site +$lists = Get-PnPList + +# Loop through each list and enable versioning +foreach ($list in $lists) { + Write-Host "Processing list: $($list.Title)" + Set-PnPList -Identity $list.Title -EnableVersioning $true + Write-Host "Versioning enabled for list: $($list.Title)" + +} + +# Disconnect from the site +Disconnect-PnPOnline From 1c3a74d413f2d877c5aed8ac30e9a455c36a2a69 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:38:55 +0100 Subject: [PATCH 94/97] Update readme.md --- .../readme.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Versioning/Enable versioning for all SharePoint Online lists/readme.md b/Versioning/Enable versioning for all SharePoint Online lists/readme.md index 19ed65b3..0b79344a 100644 --- a/Versioning/Enable versioning for all SharePoint Online lists/readme.md +++ b/Versioning/Enable versioning for all SharePoint Online lists/readme.md @@ -1,14 +1,17 @@ A short script that enables versioning for all the libraries and lists in the whole tenant. -It requires SharePoint Online Management Shell and SharePoint SDK installed: +The CSOM Version requires SharePoint Online Management Shell and SharePoint SDK installed: http://technet.microsoft.com/en-us/library/fp161372(v=office.15).aspx http://www.microsoft.com/en-us/download/details.aspx?id=30722 - +The PnP Version requires only PnP Powershell. + + +

-It uses recurrence to find all sites in all site collections and then goes through all the lists. +The script uses recurrence to find all sites in all site collections and then goes through all the lists. For some lists, enabling version may not be possible and you will receive a notification of that. At the end, a csv file is generated with the lists' urls and the status whether enabling was successful or not. From 43ee563c2465eaf29470c651bdc076599de1701a Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 1 Dec 2024 19:42:49 +0100 Subject: [PATCH 95/97] Update VersioningCSOM.ps1 --- .../VersioningCSOM.ps1 | 132 ++++++++++-------- 1 file changed, 74 insertions(+), 58 deletions(-) diff --git a/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 b/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 index 84917e55..540e1873 100644 --- a/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 +++ b/Versioning/Enable versioning for all SharePoint Online lists/VersioningCSOM.ps1 @@ -1,68 +1,84 @@ -# Created by Arleta Wanat, 2014 - - function getall($urelek){ - $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) - $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) - $ctx.Load($ctx.Web.Lists) - $ctx.Load($ctx.Web) - $ctx.Load($ctx.Web.Webs) - $ctx.ExecuteQuery() - Write-Host - Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen - - foreach( $ll in $ctx.Web.Lists){ - $ll.EnableVersioning = $versioning - $ll.Update() - $csvvalue= new-object PSObject - $listurl=$null - - if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url+$ll.Title} - else {$listurl=$ctx.Url+"/"+$ll.Title} - - $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) - $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" - - try{ - $ErrorActionPreference="Stop" - $ctx.ExecuteQuery() - Write-Host $listurl -ForegroundColor DarkGreen - $csvvalue.Status="Success" - $Global:csv+= $csvvalue - } - catch{ - $Global:csv+= $csvvalue - Write-Host $listurl -ForegroundColor Red - } - finally{$ErrorActionPreference="Continue"} + +# Script to enable versioning for all SharePoint Online lists across site collections +# Created by Arleta Wanat, 2014. Updated 2024 + + + +# Load CSOM libraries. Ensure these paths are correct on your machine. +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" + +# Define versioning setting: $true enables versioning; $false disables it. +$enableVersioning = $true + +# Function to process all lists in a site and its subsites +function Process-SiteLists { + param ( + [string]$siteUrl + ) + + # Create a client context and authenticate + $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) + $clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) + + # Load site and list data + $clientContext.Load($clientContext.Web) + $clientContext.Load($clientContext.Web.Lists) + $clientContext.Load($clientContext.Web.Webs) + $clientContext.ExecuteQuery() + + Write-Host "`nProcessing site: $siteUrl" -BackgroundColor White -ForegroundColor DarkGreen + + # Process each list in the current site + foreach ($list in $clientContext.Web.Lists) { + # Set versioning and update list + $list.EnableVersioning = $enableVersioning + $list.Update() + + # Prepare log entry + $listLog = New-Object PSObject + $listUrl = if ($siteUrl.EndsWith("/")) { "$siteUrl$list.Title" } else { "$siteUrl/$list.Title" } + $listLog | Add-Member -MemberType NoteProperty -Name "ListUrl" -Value $listUrl + $listLog | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" + + try { + $ErrorActionPreference = "Stop" + $clientContext.ExecuteQuery() + Write-Host "Updated: $listUrl" -ForegroundColor Green + $listLog.Status = "Success" + } catch { + Write-Host "Failed: $listUrl" -ForegroundColor Red + } finally { + $ErrorActionPreference = "Continue" + $Global:logEntries += $listLog + } } - if($ctx.Web.Webs.Count -gt 0){ - for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++){ - getall($ctx.Web.Webs[$i].Url) - } + # Recursively process subsites + foreach ($subsite in $clientContext.Web.Webs) { + Process-SiteLists -siteUrl $subsite.Url } } -# 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" - -# Versioning will be enabled. If you prefer to disable it for the whole tenant, change to $false -$versioning = $true +# Prompt for tenant admin URL and credentials +$adminUrl = Read-Host -Prompt "Enter your tenant admin URL (e.g., https://tenant-admin.sharepoint.com)" +$username = Read-Host -Prompt "Enter your admin username (e.g., admin@domain.onmicrosoft.com)" +$password = Read-Host -Prompt "Enter your password" -AsSecureString +$credentials = New-Object System.Management.Automation.PSCredential($username, $password) +Connect-SPOService -Credential $credentials -Url $adminUrl -# You can also enter credentials directly: $siteUrl="https://tenant-admin.sharepoint.com" -$siteUrl = Read-Host -Prompt "Enter https://tenant-admin.sharepoint.com” -$username = Read-Host -Prompt "Enter admin's login, e.g. admin@domain.onmicrosoft.com" -$password = Read-Host -Prompt "Enter password" -AsSecureString -$credy= New-Object System.Management.Automation.PSCredential($username,$password) -Connect-SPOService -Credential $credy -Url $siteUrl +# Get all site collections +$siteCollections = Get-SPOSite -$sitecollections=get-SPOSite -$Global:csv=@() +# Initialize log storage +$Global:logEntries = @() -foreach($sitecoll in $sitecollections){ - getall($sitecoll.Url) +# Process each site collection +foreach ($siteCollection in $siteCollections) { + Process-SiteLists -siteUrl $siteCollection.Url } -# Specify the path where the log file will be published -$Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv +# Export log to a CSV file +$logFilePath = "C:\Users\Public\VersioningLog.csv" +$Global:logEntries | Export-Csv -Path $logFilePath -NoTypeInformation +Write-Host "`nLog exported to $logFilePath" -ForegroundColor Cyan From 3dbd72b9eda6800a86977b04f61b2de78795af06 Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 16 Feb 2025 15:32:15 +0100 Subject: [PATCH 96/97] add pnp examples --- ...ps1 => ContentTypeManagementUsingCSOM.ps1} | 0 .../README.md | 27 +------ .../ContentTypeManagementSubsitesIncluded.ps1 | 0 .../ReadMe.md | 12 --- .../contentTypeManagement.png | Bin .../description.md | 0 .../README.md | 4 + ... EnableContentTypeManagementUsingCSOM.ps1} | 71 +++++++++--------- .../EnableContentTypeManagementUsingPnP.ps1 | 4 + .../ListContentTypes.ps1 | 67 ----------------- .../ReadMe.md | 36 +-------- 11 files changed, 47 insertions(+), 174 deletions(-) rename Content Types/Content Types Management Setting/Allow content type management for all lists in a site/{ContentTypeManagement.ps1 => ContentTypeManagementUsingCSOM.ps1} (100%) rename Content Types/Content Types Management Setting/{Allow content type management for all lists in site collection => Allow content type management for all lists in site collection with subsites}/ContentTypeManagementSubsitesIncluded.ps1 (100%) rename Content Types/Content Types Management Setting/{Allow content type management for all lists in site collection => Allow content type management for all lists in site collection with subsites}/ReadMe.md (70%) rename Content Types/Content Types Management Setting/{Allow content type management for all lists in site collection => Allow content type management for all lists in site collection with subsites}/contentTypeManagement.png (100%) rename Content Types/Content Types Management Setting/{Allow content type management for all lists in site collection => Allow content type management for all lists in site collection with subsites}/description.md (100%) rename Content Types/Content Types Management Setting/Set content type management setting for a single list/{ScriptUpdated2023.ps1 => EnableContentTypeManagementUsingCSOM.ps1} (88%) create mode 100644 Content Types/Content Types Management Setting/Set content type management setting for a single list/EnableContentTypeManagementUsingPnP.ps1 delete mode 100644 Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagement.ps1 b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagementUsingCSOM.ps1 similarity index 100% rename from Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagement.ps1 rename to Content Types/Content Types Management Setting/Allow content type management for all lists in a site/ContentTypeManagementUsingCSOM.ps1 diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/README.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/README.md index fdc22124..2612ca7c 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/README.md +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in a site/README.md @@ -1,37 +1,14 @@ A short Powershell script to allow management of content types for all lists and libraries in a site. -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)) +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)) Applies to lists and libraries. -*It requires installed* [SharePoint Online SDK](http://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. -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" - -# 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 -$Username="trial@trialtrial123.onmicrosoft.com" -$AdminPassword="Pass" -$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" -$ContentTypesEnabled=$true -``` +[Enable content type management](https://powershellscripts.github.io/articles/en/spo/enablect/) ### Please share your thoughts in the Q&A section! -#### 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) - -[Disable or enable attachments to list items using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48) - -[Change search setting for all lists in a site using CSOM and Powershell](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157) -

Enjoy and please share feedback! 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 with subsites/ContentTypeManagementSubsitesIncluded.ps1 similarity index 100% rename from Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ContentTypeManagementSubsitesIncluded.ps1 rename to Content Types/Content Types Management Setting/Allow content type management for all lists in site collection with subsites/ContentTypeManagementSubsitesIncluded.ps1 diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ReadMe.md b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection with subsites/ReadMe.md similarity index 70% rename from Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ReadMe.md rename to Content Types/Content Types Management Setting/Allow content type management for all lists in site collection with subsites/ReadMe.md index eec2be23..f0581601 100644 --- a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/ReadMe.md +++ b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection with subsites/ReadMe.md @@ -34,17 +34,5 @@ $ContentTypesEnabled=$true -#### 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](https://gallery.technet.microsoft.com/scriptcenter/Disable-or-enable-12cf3795) - -[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](https://gallery.technet.microsoft.com/scriptcenter/Allow-content-type-5bca5157) - -[Set content type management setting for SharePoint Online list using Powershell](https://gallery.technet.microsoft.com/scriptcenter/Set-content-type-39ae4bce) - -

Enjoy and please share feedback! diff --git a/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/contentTypeManagement.png b/Content Types/Content Types Management Setting/Allow content type management for all lists in site collection with subsites/contentTypeManagement.png similarity index 100% rename from Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/contentTypeManagement.png rename to Content Types/Content Types Management Setting/Allow content type management for all lists in site collection with subsites/contentTypeManagement.png 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 with subsites/description.md similarity index 100% rename from Content Types/Content Types Management Setting/Allow content type management for all lists in site collection/description.md rename to Content Types/Content Types Management Setting/Allow content type management for all lists in site collection with subsites/description.md diff --git a/Content Types/Content Types Management Setting/README.md b/Content Types/Content Types Management Setting/README.md index a8613259..4cfddffc 100644 --- a/Content Types/Content Types Management Setting/README.md +++ b/Content Types/Content Types Management Setting/README.md @@ -1 +1,5 @@ Scripts allowing you to enable / disable content type management. + + + +[Enable content type management](https://powershellscripts.github.io/articles/en/spo/enablect/) diff --git a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ScriptUpdated2023.ps1 b/Content Types/Content Types Management Setting/Set content type management setting for a single list/EnableContentTypeManagementUsingCSOM.ps1 similarity index 88% rename from Content Types/Content Types Management Setting/Set content type management setting for a single list/ScriptUpdated2023.ps1 rename to Content Types/Content Types Management Setting/Set content type management setting for a single list/EnableContentTypeManagementUsingCSOM.ps1 index 61b00e83..eac7896f 100644 --- a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ScriptUpdated2023.ps1 +++ b/Content Types/Content Types Management Setting/Set content type management setting for a single list/EnableContentTypeManagementUsingCSOM.ps1 @@ -1,36 +1,35 @@ - -# -# Created by Arleta Wanat, 2023 -# - - -# 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" - -# Insert the credentials and the name of the site and list -$Username="trial@trialtrial123.onmicrosoft.com" -$AdminPassword="Pass" -$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" -$ListName="Tasks list" -$ContentTypesEnabled =$false # change it to true if you want to enable the setting - -# Connect - $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() - -# Update the setting - -$ll=$ctx.Web.Lists.GetByTitle($ListName) -$ll.ContentTypesEnabled = $ContentTypesEnabled -$ll.Update() - -try{ - $ctx.ExecuteQuery() - Write-Host "Done" -ForegroundColor Green - } -catch(){ - Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red - } +# +# Updated by Arleta Wanat, 2023 +# + + +# 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" + +# Insert the credentials and the name of the site and list +$Username="trial@trialtrial123.onmicrosoft.com" +$AdminPassword="Pass" +$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" +$ListName="Tasks list" +$ContentTypesEnabled =$false # change it to true if you want to enable the setting + +# Connect + $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() + +# Update the setting + +$ll=$ctx.Web.Lists.GetByTitle($ListName) +$ll.ContentTypesEnabled = $ContentTypesEnabled +$ll.Update() + +try{ + $ctx.ExecuteQuery() + Write-Host "Done" -ForegroundColor Green + } +catch(){ + Write-Host "Failed" $_.Exception.ToString() -ForegroundColor Red + } \ No newline at end of file diff --git a/Content Types/Content Types Management Setting/Set content type management setting for a single list/EnableContentTypeManagementUsingPnP.ps1 b/Content Types/Content Types Management Setting/Set content type management setting for a single list/EnableContentTypeManagementUsingPnP.ps1 new file mode 100644 index 00000000..ff962d37 --- /dev/null +++ b/Content Types/Content Types Management Setting/Set content type management setting for a single list/EnableContentTypeManagementUsingPnP.ps1 @@ -0,0 +1,4 @@ + + +Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -UseWebLogin +Set-PnPList -Identity "Documents" -ContentTypesEnabled $true \ No newline at end of file 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 deleted file mode 100644 index a18ba4af..00000000 --- a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ListContentTypes.ps1 +++ /dev/null @@ -1,67 +0,0 @@ - -# -# Created by Arleta Wanat, 2015 -# - -function Set-SPOList{ - param( - [Parameter(Mandatory=$true,Position=0)] - [string]$ListName, - [Parameter(Mandatory=$true,Position=1)] - [bool]$ContentTypesEnabled - ) - - $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 - } -} - -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 - $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 - - - - - -# 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" - -# Insert the credentials and the name of the site and list -$Username="trial@trialtrial123.onmicrosoft.com" -$AdminPassword="Pass" -$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" -$ListName="Tasks list" -$ContentTypesEnabled =$false - - - - -Connect-SPOCSOM -Username $Username -AdminPassword $AdminPassword -Url $Url - -Set-SPOList -ListName $ListName -ContentTypesEnabled $ContentTypesEnabled diff --git a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md index b1663d5a..ba546a03 100644 --- a/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md +++ b/Content Types/Content Types Management Setting/Set content type management setting for a single list/ReadMe.md @@ -2,46 +2,14 @@ Short Powershell script to allow management of content types for a SharePoint On A 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 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)) +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)) Applies to lists and libraries. -*It requires installed* [SharePoint Online SDK](http://www.microsoft.com/en-us/download/details.aspx?id=42038) -You have to enter the list information before running the script: +[Enable content type management](https://powershellscripts.github.io/articles/en/spo/enablect/) - - -```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" -Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" - -# Insert the credentials and the name of the site and list -$Username="trial@trialtrial123.onmicrosoft.com" -$AdminPassword="Pass" -$Url="https://trialtrial123.sharepoint.com/sites/teamsitewithlists" -$ListName="Tasks list" -$ContentTypesEnabled =$false -``` - - -### Please share your thoughts and comments! - -#### Wiki article with detailed code description: -[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) - -#### 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)](https://gallery.technet.microsoft.com/office/Set-SPOList-properties-9d16f2ba) - -[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](https://gallery.technet.microsoft.com/scriptcenter/Change-search-setting-for-8e842a48) - -

Enjoy and please share feedback! From ce892243c9c1674c4cb59a2f666bb3550235abdd Mon Sep 17 00:00:00 2001 From: Arleta Wanat <42035526+PowershellScripts@users.noreply.github.com> Date: Sun, 23 Mar 2025 12:04:35 +0100 Subject: [PATCH 97/97] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 40096f5f..724c77ad 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Over 260 SharePoint Online scripts * bulk updates * provide automation script samples to address IT Pros' frequently asked IT tasks. -The scripts use Powershell, C#, CSOM and REST. They include copies of existing scripts from Technet Gallery years 2013-2019. +The scripts use PnP Powershell, C#, CSOM and REST. They include copies of existing scripts from Technet Gallery years 2013-2019. Most of them were tested and verified by hundreds and thousands of users of [Technet Gallery](https://gallery.technet.microsoft.com/office/site/search?f%5B0%5D.Type=User&f%5B0%5D.Value=Arleta%20Wanat)