Script Samples
Find scenarios and scripts here using tools such as PnP PowerShell, CLI for Microsoft 365, Graph PowerShell SDK and more. Are you looking for authoring tool then check out extensions PnP PowerShell and CLI for Microsoft 365 for Visual Studio Code

Modernize Blog Pages
Converts all blog pages in a site

Authenticate with and call the Microsoft Graph
Obtain a new access token for the Microsoft Graph and use it an HTTP request, or connect to the Graph

Set Page Author Byline
Sets the author by line of a modern page

Get Started with Tooltip for Connected Account
The Magic Tooltips module can be installed to help determine the account that is connected to Microsoft 365 or Azure.

Copy Custom Web Part Settings
Script to copy custom SPFx web part settings from one page to other pages

Import taxonomy terms and labels into a term set
The sample is a small set of terms to showcase the use case but the requirement was to import 100s of terms with labels into SharePoint Online.

Assign Graph permissions to a Managed Identity
A sample of script to provision Azure Function including storage account, resource group, and assign permissions

Provision Home Page to a SharePoint site
The script exports the page from a source site and provisions it to a destination site

Extract Modern Pages to Individual Provisioning Files
Script that extracts all the pages in the pages library

Extract Space content type page as template and save to SharePoint
Script that extract space content type page as template and save it to SharePoint

Get/add/update/delete list items in large lists
Get/add/update/delete items in large SharePoint list

Copy Webparts From One Page To Another Page
This script sample shows how to copy webparts from one page to another page in the same site collection.

How to to get all site collections with their sub webs
Get site collections with all the sub-webs

Generate Demo Events for SharePoint Events List
This sample script generates demo events for the SharePoint Events List within a modern site using a CSV file

Set SharePoint regional settings
Script will set custom regional settings in your sharepoint site

Create Modern Sites as alternative primary language
Create a modern site in another language as the primary language

Get SharePoint Site Collection and their Subwebs Permissions And Export It To CSV
This script sample shows how to get permission for site collection with their subwebs and export it to CSV with some required details

Detect Installed Theme
This script will detect install theme for particular site

Import CSV to an existing SharePoint List
This script shows how to import a CSV to an existing SharePoint list without explicitly enumerating all list fields

Translate columns in a SharePoint list
Say we have PowerApp that is storing its data in SharePoint lists. We want to make the app multilingual. This sample shows you the process.

Export all content from an existing SharePoint site
This script shows how to export all content from an existing SharePoint site

Setup example site
This script is a good starting point for a setup script to create site with some assets like columns, content types, lists, navigation

Add multiple lists or libraries using csv file
This script sample shows how to bulk create lists or libraries using CSV file

Clean Up Unwanted Site Columns from Content Types and Lists/Libraries
We decide we want to trim away a few of the Site Columns we've created, here is the script that does just that

Creates and apply custom list template
Script that creates and applies custom list template with custom document library, site columns and site content types

List out all Azure AD Apps along with their Credentials
This script is helpful to identify and inventorize all the Azure AD Applications registered in your tenant

Creates multiple document libraries by applying custom list template
Script that creates multiple libraries by applying custom list template with custom document library, site columns and site content types

Force Team Files Tab Provision
This script allow us to force Files tab provision, usefull for migrations or even for your Team's governance toolset..

Creates and apply custom site design with custom column types
Script that creates and applies custom site design with custom column types

Export CSV To SharePoint List Data
This script sample shows how to export CSV to SharePoint list data

Adding a new modern calendar view to a SharePoint list
This script allow you to add a new modern calendar view to an existing SharePoint list using the SharePoint REST API

Export all flows in environment
This script will get all flows in your default environment and export them for importing back into Power Automate

Report of Private Teams channels to Excel
Gathers all of the teams private channels in your tenant and produces an Excel file

Export / Import list formatting
SharePoint Online provides user interface for defining column and view formatting and forms

Create bulk dummy documents in SharePoint Document library
This script sample can be useful to upload dummy documents to SP library by auto incrementing file name

Generate Markdown Report of LCIDs
Simple report listing out the language IDs in Markdown

Inventory Guest Sign-In Activity with CLI for M365 and Microsoft Graph
Inventories Guest accounts from Azure Active Directory to query all Guest accounts and signInActivity and saves report to SharePoint List

Get Teams Templates
This script allow us to collect and export current tenant Teams Templates

Create a Teams based on a existing team template
The script first exports a selected team template and create a new team based on the template.

Add Large List items to PnP Template
Add Large list items to PnP Template using PnP command

Clone a Microsoft Team with\without content
This script allow us to clone an existing team (structure and content!) into a new one with changed attributes including content.

Run jobs in parallel using ForEach-Object -Parallel to iterate SharePoint site collections
This script sample shows the basic of using ForEach-Object -Parallel to speed up trivial SharePoint operations across many site collections

Get SharePoint Site Recycle Bin Items And Export It To CSV
This script sample shows how to get recycle bin items from SharePoint site and export it to CSV

Replace a user's membership in selected Microsoft 365 Groups or Teams
Replace the membership of a user for a selected list of Groups

Get All Apps From The App Catalog And Export It To CSV
This script sample shows how to get all apps from the app catalog and export it to CSV.

Delete a library exceeding the list threshold limit
Delete a large SharePoint library by removing the files and folders before deleting the library

Flow run status list dashboard
Powershell script that reports the status of the latest run of all flows by writing to a M365 list

Export a csv report on all Microsoft Stream videos
This script export a report on all Microsoft Stream videos (complete list and all videos not yet migrated)

Remove orphaned redirect sites
Provides you with an overview of all orphaned redirect sites and allows you to quickly delete them

Get Site Usage Reports And Export It To CSV
This script sample shows how to get all site collections with usage information and Export to CSV.

Analyze users for known data breaches with have i been pwned
Validate all your users against known breaches with the have i been pwned api. That way you can quickly scan if your users are part of any known breaches

Modernizing classic pages from on-premises sites
Conversion of an on-premises 2013 publishing page to the modern experience

List all teams and teams members in Microsoft Teams in the tenant
List all teams and teams members in Microsoft Teams in the tenant and exports the results in a CSV

Teams Full Report
Script to generate Team's full report, gathering all Teams,Channels,Tabs available info.

Exporting Document libraries inc folders and versions for selected Site Collections to a Fileshare/drive
The purpose of this script is to exporting Document libraries inc folders and versions for selected Site Collections to a Fileshare/drive

Get permission group report of a site
The scripts get group permission report of site and each list on the site and prints it to console and also sends it as an adaptive card to Teams channel specified by webhook.

Add a tenant theme to SharePoint Online
This is example for adding a SharePoint Theme as an option for modern sites in the tenant

Bulk Convert Classic Publishing Pages to Modern Pages
The sample script converts all SharePoint online classic publishing pages in a site collection to modern pages in a modern site

Create Modern SharePoint Pages and add web parts
Create modern SharePoint pages and adding web parts without using a provisioning engine

Undelete items from SharePoint Recycle bin
This script allows users to undelete items from recycle bin and restore it in respective document library and list.

Delete custom SharePoint list designs
Remove List designs and corresponding site scripts.

Export a csv report on all Whiteboards
Export a report on all Whiteboard owners and it's usage.

Export OneDrive Admins
Exports every OneDrive in the tenant, and the site collection admins. Audit which admins have access to user OneDrives.

List guests within Teams in a tenant
List all guests in Microsoft Teams teams in the tenant and exports the results in a CSV.

Get Hub Sites Information And Export It To CSV
This script sample shows how to get hub sites information and export it to CSV

Update user profile properties
This script sample shows how to update user profile properties.

Flows runs day summary
This script creates a report of all flow runs from current day and sends the report as an adaptive card to the provided url

Run A Search Query And Export To CSV
Perform a search query (such as 'Show me all News Posts in this tenant') and export the results to CSV.

Bulk library generation
With this sample, you can create a whole bunch of libraries at once.

Get SharePoint List Fields With Required properties And Export It To CSV
This script sample shows how to get list fields with some required propertiesand export it to CSV

Script allow copy column format in SharePoint and apply to different column.
Copy column format from column or web sample and apply to different column

Get SharePoint List Or Library Permissions And Export It To CSV
This script sample shows how to get permission for list/library and export it to CSV with some required details

Fetch User Profile Properties From Site Collection And Export To CSV
Get users or user profile properties from any SharePoint site collection and we need it in CSV or Excel format

SharePoint Online Hub Site Association
This script sample shows how to associate SharePoint online site with a hub site.

Install and deploy SPFx solution
Install and deploy SPFx solution to the SharePoint site

Create bulk dummy documents inc versions in SharePoint Document library
This script sample can be useful to upload dummy documents and versions to SP library by auto incrementing file name

Export SharePoint List Data to CSV with attachments
This script sample shows how to export SharePoint list to CSV with attachments

Add/Remove users(bulk) from Power Apps from CSV file
Script which will help to provide bulk access to Power Apps from csv format

Read SharePoint List Items Using CAML Query
This script sample shows how to get SharePoint list items using CAML query with different types of fields

Bulk Create Teams with JSON File
Create teams in an environment to test governance scenarios making over a 1000 teams - this sample script can generate the required teams.

Copy library view to another library(ies)
The script copies a library view to library(ies) in destination site

Get Flows Connected to SharePoint
This script Gets all the flows connected to a SharePoint site

Planner migration to SharePoint list
Migrate a planner plan with buckets and tasks to a SharePoint Online list

SharePoint Modern Page Publishing Report
Scan through modern pages within a site and reports out the publishing status of the pages

List all external users in all site collections
Script helps you to list all external users in all SharePoint Online sites

List external users across all sites and in what site groups they are
The script shows in what site groups external users are added in all SharePoint Online sites

Copy Planner plan
With this sample, you can copy an existing plan to a certain group.

Update web part properties on modern pages
Update web part properties on modern pages

Bulk Publish Syntex Models To Libraries
This script sample will publish Syntex Document Understanding Models to many libraries using the batching functionality of PnP PowerShell.

Create a SharePoint site using the configuration of another site
This script uses PnP Powershell to extract the template of one SharePoint site and invoke it on another site

Add a document library web part to a page
Add a document library web part to a page (and only show a specific folder)

Restore large number of items from SharePoint Recycle bin in bulk
Restores Recycle bin items from CSV file in batches

Get Azure AD app permission info (delegated or application)
Get any existing delegated or application permission info associated to a Microsoft AAD app from its name

Export checked-out files in all sites associated with a hub site to CSV
Export checked-out files in all sites associated with a hub site to CSV

Get notified in Microsoft Teams about SharePoint health incidents
This script monitors your SharePoint health status and sends a notifications to a Microsoft Teams channel.

SPO Recover Deleted Meeting Recordings
With the new 120 day expiration meeting recording policy - what do you do if you need to recover across thousands of accounts.

Microsoft Graph PowerShell SDK for Common Operations
Examples of common operations covering installation, authentication, permissions, differentiate between endpoints, CRUD operations are more...

Get all files in a Document Library along with Created By and Modified By
When connected to a site with Connect-PnPOnline this script will walk through the site's document libraries, list each file, when it was created and by whom, and when it was last modified by whom

Get users by license and review last signed in
Obtain a report via the Microsoft Graph to extract the license and last signedin information to support a license review, for others to help remove any unused users

Create a Quick Links web part with items defined in a datasource
This script will enable you to create a Quick Links web part where the items are defined in some kind of data source

Add Content Type Hub with calendar format field to List
This script will create Content Type Hub with custom calendar List field formatting and include in destination site and associated custom List

Export SharePoint Term Store terms to CSV
Export SharePoint Term Store terms to CSV

Update content type of files in folder with system update
The script updates content type of files in folder with system update.

Change the Placeholder text in SharePoint Search Box
This sample script shows how to change the placeholder text in SharePoint online search box for a given (sub) site and/or for all the sites in a site collection.

Export all site pages details from Site Pages library
This script sample shows how to export all site pages details from Site Pages library.

Sample on how to locate the classic Search Result Web part and check the Remove Duplicates setting
Locate all the pages where a classic SearchResultWebPart is used, and if the Remove Duplicates setting is True (which is the default) log the location in the csv file

Delete orphaned temporary pages from Site Pages
Script to clean up temporary pages from Site Pages library

Export OneDrive Sites
This script exports all onedrive sites to CSV

Delete all resources from a resource group
There will be cases where you want to delete all resources from a resource group. This would typically be used if you want to clean up the resource group after a test run.

Copy the folder structure of a directory to a SharePoint list
Copies the folder structure of a directory to a SharePoint list and trigger an migration using the Migration Manager

Gets usage from a particular user(s) or site(s) from the Unified Audit Log
This script will scan the ULS Logs for the last week looking for all access by a user an or to a site and create an excel file summarizing the activity

Sample showing how to export basic site collection properties to a CSV file
Sample showing how to export basic site collection properties to a CSV file for stakeholders which do not have access to the SharePoint Admin Center

Add demo content from a website such as Wikipedia
This sample shows how you can generate a set of demo content from a website such as Wikipedia.

Remove modern web parts from pages
Remove modern web parts from pages by their Id, Instance Id, or Title

Create a multi-hub set of communication sites
This sample builds 9 SharePoint communication sites, creates three hub sites and associates them to a main hub site

Extract the configuration of a PnP Modern Search results web part and apply it on another site collection
Sample showing how to use extract the configuration of a PnP Modern Search results web part and apply it on another site collection

Extract the employees shown in the People Web part on pages in a selection of Site Collections to CSV
Sample showing how to extract the employees shown in the People Web part on pages in a selection of Site Collections

Extract the employees shown on modern pages (Author byline) in a selection of Site Collections to CSV
Sample showing how to extract the employees shown on modern pages in a selection of Site Collections

Uploads a large file to SharePoint using MS Graph REST API and PowerShell
Uploads a large file to SharePoint using MS Graph REST API

Deploy sppkgs and install apps
Deploy all packages from a local folder and install the apps to the SharePoint site.

Enable Site Collection App Catalog on a specific sites using CSV
Enable Site Collection App Catalog on list of SharePoint sites from CSV

Create Dynamic Install and Uninstall Azure AD Groups using Graph
Script will create dynamic user groups based on the user having an enabled license for each application

Create Documentset in SharePoint Library
Sample for when you need to work with documentsets in SharePoint

Create AD app, add permissions and connect to SharePoint
Create AD app, add permissions and connect to SharePoint

Download Library contents as PDF
Script to download files in a doclib to a local drive and convert Office Documents to PDF

Enable page scheduling on a modern site pages library
Enable page scheduling on a modern site pages library

Creates and apply site designs
Script that creates site design based on existing site with permissions

Report of where a Term is used
Lists all the places where a specific Term ID is used

Retrieve Message Center announcements and post to MS Teams channel
This script allows you to retrieve Message Center announcements and post to MS Teams channel.

Export of pages that use Stream (Classic) Web Parts
This sample script helps you understand how many Stream (Classic) Web Parts are being used by your site by outputting a CSV file of the Stream (Classic) Web Parts and the pages that use them.

Grant permissions for a given Azure Active Directory application registration
Simplifies the process of granting FullControl or Manage permissions for an application registration in a SharePoint site collection

Sample showing how to ensure that the Role/Title in each People web part is updated
Sample showing how to ensure that the Role/Title in each People web is updated

Compare files hash from two different SharePoint tenants
This script will compare files hash from two different SharePoint tenants

Bulk import data from multiple files
Script that bulk imports data from multiple files

Bulk Email Send from CSV using Microsoft Graph API
This script can be used to send bulk emails to multiple users from CSV file on behalf of user

Pinpoint the items/docs that hasn't been indexed yet
Pinpoint the items/docs that hasn't been indexed yet since the last time the item was updated

Export access shared links from SharePoint Library
Script will export SharePoint Library with access shared links files to CSV file.

Use Invoke-PnPSiteTemplate with parameters
Sample showing how create a PnP Template and ADD parameters then use Invoke-PnPSiteTemplate with parameters

Add users to follow SharePoint Sites
This script helps M365 admin to provision follow SharePoint Online sites to users and display in Out of the box SharePoint Site /_layouts/15/sharepoint.aspx?v=following.

Multilingual SharePoint Page Summarization with Open AI API and Microsoft Graph PowerShell SDK
This sample demonstrates how to use Microsoft Graph PowerShell SDK and Open AI API to generate a multilingual summary of a SharePoint page.

Locate all Teams having a Wiki and export the list to CSV
Locate all Teams having a Wiki and export the list to CSV

Create test users from list or use ChatGPT to generate
Create test users with chat and GPT or use predefined list of users

Using a PnP Site Template including files and list items
Sometime you are required to create a site including some specific files and/or list items. You can do this in servaral ways, but in this sample we are using the PnP Provisioning Engine

Export User Profiles to csv
This sample shows how to export all or a sub set of accounts from UPA to CSV

Change SharePoint Online List URL
This sample script shows how to change SharePoint online list URL and rename the list after list creation using PnP PowerShell

Getting checked-out files in the tenant using Search
Getting checked-out files in the tenant using Search

Apply SharePoint JSON View Formatting
This sample script shows how to apply SharePoint JSON view formatting using PnP PowerShell and CLI for Microsoft 365

Get Content Type usage within a site collection.
Get Content Type usage within a site collection.

Download sppkgs from App Catalog
Download all packages from App Catalog

Disable SharePoint List Commenting at list level
This sample script shows how to disable commenting feature in SharePoint online lists at list level

Delete custom SharePoint site scripts
Remove Site scripts that ends up just hanging around in your tenant. Use the scripts below to get rid of them

Delete custom SharePoint site designs
Remove Site designs and site scripts that ends up just hanging around in your tenant. Use the scripts below to get rid of them

Add App Catalog to SharePoint site
Deploy certain SharePoint solution to a specific site

Empty SharePoint Online Site Recycle Bin
This sample script shows how to empty SharePoint online site first stage and second stage recycle bin

Remove Title Area from SharePoint Page
This sample script shows how to remove the title area from SharePoint online site page using PnP PowerShell and CLI for Microsoft 365.

Add Page template to Site
This sample script shows how to add a page template to a SharePoint Online site collection

Update SharePoint Page Banner Image
This sample script shows how to update the banner image at the top of the SharePoint online modern page using PnP PowerShell

Activate a site feature in SharePoint online
This sample script shows how to Activate a site feature in SharePoint online site.

Set Home site for SharePoint online tenant
This sample script sets a communication site as a home site for SharePoint online tenant

Associate Multiple Site Collections to Hub Site
This PowerShell script can be used to associate mutilple site collections to Hub site. You can provide list of site collection URLs in an array.

Disable SharePoint List Commenting at tenant level
This sample script shows how to disable commenting feature in SharePoint online lists at tenant level

Enable modern creation forms for Document sets
This sample script shows how to enable modern creation forms for Document sets in SharePoint online site.

Open Office documents in the Client
Ensure that office documents will open in the desktop client application if such is installed

SharePoint Modern Page URL Report
Scan through modern pages and reports out the URLs in the quick links web parts

Hide SharePoint list from Site Contents
Hide the SharePoint list from the UI this script will hide a specific list from the site contents

Empty the tenant recycle bin
Script that removes sites from the tenant recycle bin

Create SharePoint Groups in Bulk using CSV file
This script shows how to create multiple groups in SharePoint for different site collection providing input from CSV file.

Find all items with unique permissions and export to csv
Find items where the permissions have been broken

Download all the content type document templates files associated with a library
The script downloads all content type document template files in a library

Delete custom color themes from SharePoint
Creating a lot of beautiful themes lately and testing them but don't want to keep them anymore, this script is for you

Add/Update Image in SharePoint Image column
Add/Update image in SharePoint image column in a SharePoint List or Library

Enable and Disable App Bar in SharePoint Online
This script helps SharePoint Users to Enable or Disable App Bar Across SharePoint sites

List all Microsoft Teams team's Owners and Members
This script allows you to list all Teams team's owners and members and export them into a CSV file.

Allow custom scripts in SharePoint online site
This sample script shows how to allow use of custom scripts in SharePoint online at site level

SharePoint List Item Version History Retrieval
This script retrieves the version history of a specified list item, including all field values or only selected fields

Deactivate User License
This script connects to Micrsoft Graph and searches all Microsoft E3 Licenses for YAMMER_Enterprise licenses. It will then deactivate the Yammer license within Office 365, it can be used to remove other Office 365 licenses as well

Reset files permission unique to inheritance
Reset bulk file permissions from unique to parent folder inheritance.

Remove delete option on a document library
Remove the delete option on a document library to prevent users from accidentally deleting libraries

Associate Form Customizer Extension with List or Libraries Form
This script allows you to associate Form Customizer Extension to List/Library via Content Type properties

Get TfL (Transport for London) status with OpenAI function calling feature
This sample shows how to use OpenAI's function calling feature and get status of a TfL line.

Generate a csv report for a selection of site collections showing the time of the most recent update by any user
This script show the date of the most recent update

Deploys and Installs SharePoint Framework (SPFx) solutions to Hub Site and Associated Sites
Deploys and Installs SharePoint Framework (SPFx) solutions to Hub Site and Associated Sites

Testing user preferred language of SharePoint site
Changes the MUI setting for a user within the User Information List

Connect to Graph using V1 or V2 or the SDK
This function detects the graph version and connects accordingly

Get storage breakdown by file size, file version size and recycle bin
Get storage breakdown by file size, file version size and recycle bin.

List of active sites in Tenant with Admins and storage used
This script provides you the list of active sites in your tenant with their administrator and usage in MB

Bulk delete recycle bin items from a site in batch
This script will delete items from recyclebin in bulk while avoiding List View Threshold issues.

Update large list with PnP-Batch with retries to address throttling challenges
This sample shows how to efficiently update a large SharePoint list of 60,000 or more items using PnP-Batch, significantly reducing update time.

Add SharePoint Framework package to the app catalog and Azure AD app certificate
This is example script how to add SharePoint Framework package to the app catalog using Microsoft 365 CLI and Azure AD app certificate.

Get sites report throughout the tenant which has unique permissions
This scripts gets the report of sites in a tenant which is having unique permissions

Copy SharePoint List
Script to copy SharePoint list to a different site

Find Web Part in Pages e.g., Twitter Web Part
Find a specific Web part in pages or templates, for example, defualting to and finding Twitter Web parts

Create Colored Folder
This sample code creates a Colored Folder in a SharePoint document library.

Create Library and add custom Content Type
Script to create SharePoint document library and add custom content type

PnP Modern Search V3 usage scanner
Find the pages where a v3 of PnP Modern Search web parts have been used, export report to CSV

Export Inactive Sites Based On Days To CSV
This script exports all inactive sites based on certain number of days to CSV.

Export Teams's Channel Conversation to html file
This PowerShell script will export the teams channel conversations to an HTML file with expand collapse feature based on Teams and channel.

Report of SharePoint Files Incidents
Tracks the list of people who edit each file and exports the complete list of editors in the library. This allows us to identify users who shouldn't have editing rights or those who edited files only occasionally and then stopped.

Bring you own data with Azure Open AI example
Using Azure Open AI and Azure Cognitve Search with Semantic Index, this example shows how you can call the AI service with your own data.

Add an alternate language to SharePoint Online Site
This script adds a new language to the SharePoint Online site with the help of language LCID decimal.

Copying files between different SharePoint libraries with custom metadata
This sample shows how to copy files between different SharePoint libraries with custom metadata with a matching folder structure.

Backup all custom formatting on a site
A script that let's you easily backup all custom formatting on a site

Get membership report of a site
The script export site membership details to a CSV file

List and archives inactive Teams
This script lists and archives all the inactive teams

Add or Update User Photo
The script streamlines the process of updating user photos of images stored locally. It ensures efficient handling of both successful updates and errors, providing an organized approach to managing user photos within Microsoft 365

Get disabled or inactive user accounts
Find the user accounts which have been disabled or are inactive, export report to CSV

Export all List and Libraries with Item count and Permission in CSV
Get all lists and Libraries along with total Item count and permissions and export it in CSV

Creation of SharePoint Online sites from CSV
This script helps you in creation of SharePoint Online Communication and Team sites in bulk. It takes an input from CSV.

Export Microsoft Teams Direct Routing Calls
Exports the log of direct routing calls for a given duration

Export Microsoft Teams PSTN call logs
Exports the log of PSTN calls for a given duration

Create fields and add to Content Types
Script to create site columns and add them to content types

Disable Quick property editing (Grid view) from SharePoint list
This sample script will show you how to disable the Quick property editing (Grid view) from SharePoint list.

Send a delayed message
This script shows how to send a delayed message with the Microsoft Graph PowerShell SDK

Export HTML content from SharePoint Online modern pages

Simple way how to automate your flowtest
You can use my Script as a base to build your own automation for testing flows.

Disable Web Templates Gallery First Run Dialog
Disable Web Templates Gallery First Run Dialog

Get all PowerApps in your tenant
Sample script to create a lists of all apps in your tenant and exports to CSV

Reorder Content Types in SharePoint List
This script guides how to rearrange content types in a SharePoint list using PnP PowerShell.

Fetch Microsoft Teams Details And Export To CSV
Retrieve team information such as team name, ID, owner, channels, etc., and export it to CSV using Microsoft Teams PowerShell.

How to Hide the 'See All' Button in the Highlighted Content Web Part
This sample shows how to Hide the 'See All' Button in the Highlighted Content Web Part using PnP PowerShell

List installed apps within Teams in a tenant
Exports the installed apps in Microsoft Teams teams

Export and import library folder structure
This script shows who to export a folderstructure to a JSON file, and import the folder structure into another library

Get Checked Out Files including those with no checked in version
This script sample shows how to get checked Out files including those with no checked in version

Enable/Disable Search Crawling on Sites and Libraries
Control the sites and libraries that get crawled. Also useful for Copilot projects to chose which areas to include

Bulk remove retention labels from files in a SharePoint Library
Bulk remove all retention labels from all files in a library that are labelled with a retention label. These files will now no longer be tagged with a retention label

Export all PowerApps details and its Role assignments from Tenant in CSV format
This script sample how to export all the PowerApps details and its role assignment in csv format

Get All Hub Site Main Sites and Navigation Nodes
Get all hub site main sites and navigation nodes using PnP PowerShell and update nodes if required.

Request Reindex of SharePoint User Profile Properties
This function, Request-PnPReindexUserProfile, triggers a full crawl of each user's profile properties.

Get Site Collection invalid user accounts
Find the user accounts which no longer is valid, export report to CSV

Replace specific users in the People web part
Replaces specific users in the People web part

Add bulk users to SharePoint site groups from CSV.
Add bulk users to SharePoint site groups from CSV.

Add dummy folders and files to a SharePoint library
This sample shows how to add dummy folders and files into a SharePoint library, generating files within folders to perform testing.

Add multiple folders in libraries using a CSV file
This script will create the folders (not nested) into the libraries provided in the CSV file.

Download all files from array of documents urls and archive them
The script downloads all files from array of documents urls and archive them to a zip file

Register SharePoint Organization Assets Library
This sample script shows how to register a SharePoint document library as an organization assets library.

Remove SharePoint Organization Assets Library
This sample script shows how to remove a SharePoint document library from organization assets libraries.

Get Unified log for SharePoint DLP Exchange and Entra
Understand and track activities within your M365 environment is crucial for maintaining security and compliance.

Report and Export Solutions from M365 Developer Tenant
Expiring tenant or need to understand what you have created in the past, report and optionally export your projects and solutions

Copy a hub navigation from a source site to any desired target hub site
This script copies a hub navigation from any hub site (source) to another hub site (target)

Reindex SharePoint sites
Keeping your SharePoint environment up-to-date is crucial, especially after making schema changes - this script streamlines the process of reindexing sites, libraries, or lists.

Export of the Hierarchy of Hub Sites
This script exports the SharePoint site hierarchy into a Markdown file to visualize the hub sites and its associated sites.

How to retrieve the hierarchy of all term stores for all levels?
How to access complete term store hierarchies across all levels?

Export Content Type Details To CSV
This script exports all content types available on a SharePoint site to CSV.

Scan for potential inaccessible site collection homepages
Looks for site collections where the home page has custom permissions and outputs to a CSV file.

Replace an owner in a Microsoft 365 Group or Microsoft Team
Find all the Microsoft 365 Groups that a user is an Owner of and replace them with someone

Delete all Microsoft 365 groups and SharePoint sites
Sample shows how you can delete Microsoft 365 Groups and associated SharePoint Online sites in your development environment

Get custom fields within lists and libraries within a site
Get custom Fields within lists and libraries within a site.

Retracting SPFx Solutions from Hub Site and associated sites
Retracting SPFx Solutions from Hub Site and associated sites

Deploying SPFx Packages from Tenant App Catalog to Hub Site and Associated Sites
Deploying SPFx Packages from Tenant App Catalog to Hub Site and Associated Sites

Trim file versions and archive Site Collection using Microsoft365 Archive
Trim the file versions and archive the site using Microsoft 365 Archive

M365 Consultant's Script Kit
These scripts are part of the Microsoft 365 Consultant's Script kit - OneDrive, SharePoint and Custom Site Scans

Query advanced CSOM properties with PnP PowerShell
This sample shows how to query CSOM properties with PnP PowerShell by writing C# code, importing it in PowerShell and sending a single Invoke-PnPQuery request

Locate orphaned Termstore Terms
Locate all instances of Managed Metadata where the connected Termstore Term has been deleted

M365 Consultant's Script Kit - Change Retention Labels
This will scan every SharePoint site (or OneDrive URL) and look at every item. When it does this, it will check the retention label for said item.

Retrieves all files properties within a specified folder.
Retrieves all files properties within a specified folder.

Get (or export) an existing site structure in a SharePoint Online tenant
Retrieve an existing structure of a SharePoint Online (SPO) tenant

Repair IdMismatch for user cross all Sites
This script will fix the IdMismatch of a user across all sites.

Delete SharePoint Online sites that have retention policies
This sample script deletes specified SharePoint Online sites that have a retention policy applied by excluding them from the retention policy, deleting the site and then cleaning up the retention policy exclusions.

Reindex Search index for lists where a specific term is used (when you have renamed the term)
Locate all lists where a Term is being used and force a reindex

Replace owner in all Power Automate flows
Script to replace all the Power Automate flows where someone is owner of

Ensuring m365 group owners are m365 group members
Ensuring m365 group owners are m365 group members

Get All Teams App Descriptions
Get an list of all the app descriptions to determine if your app may clash with others during Copilot development

Deletes sharing links for folder, file and item in SharePoint
Deletes sharing links for folder, file, and item. This can address oversharing issues during the Copilot for M365 rollout.

Remove site access requests
As a site owner, delete in bulk all the access requests from a SharePoint site.

Update a SharePoint list item without changing the Modified By and Modified fields
Demonstrates how to update a SharePoint list item without changing the Modified By and Modified fields using PnP PowerShell.

Find SharePoint Framework (SPFx) Packages in Tenant and Site Collection App Catalogs
Find SharePoint Framework (SPFx) Packages in Tenant and Site Collection App Catalogs which will help maintain oversight of SPFx package installation, ensuring they are up-to-date and compliant.

Update SharePoint Site Logo and Thumbnail
Update SharePoint Site Logo and Thumbnail.

Remove the Teamify link on Group sites
Remove the link in the left hand side suggesting to convert a Group Site to a Teams site

Get sharing links within the tenant
Understand and sharing links activities within your M365 environment is crucial for maintaining security and compliance.

Get SharePoint Storage Usage Against Allocated Quota
Understand and sharing links activities within your M365 environment is crucial for maintaining security and compliance.

Retrieve SPFx Details from Tenant and Site Collection App Catalogs
Retrieve detailed information about SPFx solutions installed in SharePoint environment, such as API permissions from both the tenant-level and site collection app catalogs.

GET API Permissions for SPFx solutions
To enhance your tenant's security posture, it's crucial to regularly review the API permissions requested by SPFx solutions

Ensure all required Content Types are available before Get-PnPSiteTemplate
This is a Content type pre-burner before extracting a PnP Template

Find every page that contains a Modern Script Editor web part
Locate use of Modern Script Editor

Remove unused API Permissions assigned to SPFx App Principal
This script removes unused API permissions assigned to the 'SharePoint Online Client Extensibility Web Application Principal'.

Grant Managed Identity permissions to audit and cleanup SPFx App Principal permissions
This script can be used to grant System-Managed Identity used by automation (Azure Runbook, Azure Functions) API permissions and access to SPO sites

File Version Trimmer
This sample shows how to delete a number of file versions to reduce SharePoint Storage

Microsoft 365 License Monitoring and Alert Script
This script is designed to help administrators monitor the availability of Microsoft 365 licenses for specific SKUs

Register and login to SharePoint using an app
This script sample shows how to register an app in SharePoint and login to SharePoint using the app.

Audit Service Principal Access to SharePoint Sites with Sites.Selected Permissions
This script identifies the SharePoint sites that a Service Principal can access when the sites.selected API permission is granted.

Report of SharePoint Storage Savings by trimming document versions
This script creates an overview for The total amount of SharePoint Storage, and how much could be saved by trimming the versions.

Get Files with Retention or Sensitivity Labels in SharePoint Online
Get Files with Retention or Sensitivity Labels in SharePoint Online

Get permissions including unique permissions up to item level including sharing links
Get M365 Groups, SharePoint Groups, direct permissions and sharing links including unique permissions up to item level

Download all files from Document Libarary/Folder
The script will download all files from an SharePoint Document Libraray or Folder

Add document templates to the New dropdown in a document library
Showing how you can add your own document templates to the the New dropdown in a document library

Delete inactive Guest User
The script will report inactive users for x days and provides an option to delete them.

Update list icons & color
A sample showing you how to change the color or the icon of a list in SharePoint

List ownerless teams
Easily identify ownerless teams in your tenant

Generate file count report
Get a full report of the number of files in your environment

Get all Bootstrap Icons to use in your powerapps
This PowerShell script downloads the latest [Bootstrap icons](https://icons.getbootstrap.com/) from [twbs@github](https://github.com/twbs/icons/releases/latest), creates a JSON file with the complete list of SVG icons you can use.

Get SharePoint site sharing Settings
Get SharePoint site sharing settings including some SharePoint Advanced Management(SAM) settings

Automate Renewal of Expiring M365 Groups or or Microsoft Teams teams
Automate Renewal of Expiring M365 Groups or or Microsoft Teams teams

Prevent Guests from Being Added to a Specific Microsoft 365 Group or Microsoft Teams team
Prevent Guests from Being Added to a Specific Microsoft 365 Group or Microsoft Teams team

Get Tenant ID
These are 2 practical scripts to get Tenant ID from either a domain name or from a Subscription ID.

Lock and Unlock a file leveraging Microsoft Graph API
lock and unlock a file which is a record in SharePoint Online using the Microsoft Graph API through PnP PowerShell. The script retrieves the drive id and drive item id before calling the endpoint to lock or unlock a file.

Retrieves site id from Microsoft Graph
Retrieves a SiteId from Microsoft Graph using PnP PowerShell. This can be particularly useful when making further API calls that require the SiteId.

Export data from MS Search
Shows how to export data from MS Search, in this case the entityType externalItem

Audit 'Everyone' and 'Everyone except external users' claim within a SharePoint site
Audit 'Everyone' and 'Everyone except external users' claim within a SharePoint site

Update Global Microsoft 365 Group Settings
Configuring Microsoft 365 Group settings is essential for ensuring a secure and compliant environment. This script can be utilized to set up different group settings, such as naming policies and guest access.

Get Site Ids to URL
This script takes an input file containing one or more SharePoint Online Site Collection Object IDs and converts them into the full URLs

Find Links in Modern Page
This script iterates through a list of site URLs provided in 'sites-test.csv'. For each site, it then scans these page contents for embedded href tags using regular expressions.

Get sites membership as an admin
The script retrieves information about a site's default group memberships and administrators for SharePoint admins, without requiring permissions for specific SharePoint sites

Identifying Duplicate Microsoft 365 Group Names
Identifying duplicate M365 Group to ensure each group has a unique name can help to reduce confusion for end users.

Retrieving SharePoint Site URL for Teams Channels
This script can help to identify the SharePoint Urls associated to private and shared channels. For example, eDiscovery when running against 'Specific Locations' or just for reporting purposes

Copying a document library between different tenants with resume functionality
This sample shows how to copy a document library including files and folder structure from one tenant to another one. It includes a resume functionality which comes handy for large libraries. Additionally you can specify custom properties which shall also copied to the target.

Download all documents from all document libraries in a site, including version history
This PowerShell function will download all documents from all document libraries in a site, including version history. The documents will be saved in a folder structure that matches the library structure.

Retrieve & Store SharePoint Site Pages Viewers
This script retrieves and stores SharePoint site pages viewers' details.

Deletes company-wide and anonymous sharing links
Deletes company-wide and anonymous sharing links for folder, file, and item. This can address oversharing issues during the M365 Copilot rollout.

Creating SharePoint Agents (.agent Files) with PowerShell
Dyanmic creation of SharePoint Agents (.agent files) using PowerShell. Specify instructions, sample prompts and ground on files, folder, libraries or sites.

Deletes expired and older sharing links for folder, file and item in SharePoint
Deletes expired and older sharing links for folder, file, and item. Currently expired or older sharing links are not automatically deleted

Get data from OpenAI deployment/model
This sample shows how to use both OpenAI and document intelligene studio to process and extract data in a json format

Integrate MailChimp Campaigns API with SPO to create wiki pages based on email sent from MailChimp
Demonstrates how to retrieve sent email campaigns from MailChimp, and save them as wiki pages on SPO. The script retrieves the HTML content of the email, downloads all images into a local folder and uploads to a SPO document library, replaces all mccontent image tags to point to SPO, and create and publish a wiki page

Scan libraries for webhook and export to csv
Scanning document libraries and reporting on those that contains 1 or more webhooks

Hide people who have lists open
This sample script demonstrates how to hide real-time viewing information in Microsoft Lists.

Get SharePoint Agents
Get a list of SharePoint Agents from SharePoint Online site and export agent metadata and contents to CSV.