Sample scripts for the PnP PowerShell cmdlets
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Items
Lists
Permissions
Search
Sites
LICENSE
README.md

README.md

PnP-Samples

Sample scripts for the PnP PowerShell cmdlets. These scripts were developed by myself and used in real-life scenarios, but are often kept simple (e.g., they usually don't use parameters; variables are set directly in the script) and can be expanded/update if wanted. Feel free to submit Issues or Pull Requests to improve them

Lists

Script Description
GetListDetails This script creates an inventory of the lists and libraries in a site, similar to what's available in the Site Contents page
GetVersioningDetails This script retrieves all versioning details from all lists in a provided site, including 'Require Content Approval','Versioning Enabled','Major Version limit','Draft Version limit', 'Drafts visible to', and 'Checkout required'
VerifyListForms This script checks all lists in all subsites and verifies if the lists have the three forms (View, Edit, New) set. If at least one of them is not available, the script will log the list to a report file

Items

Script Description
UpdateContentType This function updates all items in a given list/library from one content type to another

Permissions

Script Description
GetPermissionLevels Retrieves the permission levels from all site collections (excluding OneDrive) and stores them in a CSV file
SetSiteCollectionAdministrators Sets a list of site collection administrators on specified sites (selected via filter) in the current tenant

Search

Script Description
SetSearchIndexing This script sets the "Indexing Site Content" setting under "Search and Offline Availability"
SetSiteCollectionSearchSettings This script sets the search center URL as well as the seach results page URL for a given site collection

Sites

Script Description
GetSiteCollectionStorageDetails Retrieves size information for all site collections in a tenant and exports it to a CSV file
RecursivelyDeleteSubsites This script recursively deletes all subsites for a given site and the site itself