Skip to main content

Posts

Automate SharePoint Site Creation with PowerShell and PnP

Creating new SharePoint sites while maintaining a consistent look and feel can be challenging. Fortunately, with PowerShell and the PnP (Patterns and Practices) framework, we can automate the process of backing up a site template and applying it to a new site. This blog post will guide you through the necessary steps. Prerequisites Before you begin, ensure you have the following: SharePoint Online Management Shell PnP PowerShell module installed Appropriate permissions to access the SharePoint site and admin center Step-by-Step Guide 1. Backup the Site Template First, you need to connect to the source site and back up its template. # Source Site URL input $SourceSiteURL = Read-Host "Enter Source Site URL" # Path to XML file $SchmaXMLPath = " " # Connect to PnP Online to take template backup Connect-PnPOnline -Url $SourceSiteURL -Interactive # Get Site Schema and save to file Get-P
Recent posts

Identifying Stream Web Parts in SharePoint Pages

Microsoft recently announced that they are discontinuing the classic Stream and introducing a new version. This change necessitates the identification of Stream web parts across SharePoint pages within your organization. To help with this transition, you can use a PowerShell script to scan your SharePoint sites for any Stream web parts that may be in use. Below is a detailed explanation of how to achieve this using PowerShell and the PnP PowerShell module. Script Overview The script provided here connects to your SharePoint Online sites, iterates through all site pages, and checks for the presence of Stream web parts. It compiles a list of these pages and exports the information to a CSV file. Key Components of the Script 1. Parameters and Global Collection Initialization $PagesDataCollGlobal = @() 2. Function Definition: CheckWebParts This function connects to a given site, retrieves all site pages, and checks each page for Stream web

Generate List of SharePoint Pages and Owners Using Power Shell

Managing a large SharePoint site with thousands of pages can be daunting, especially when you need to get a detailed list of pages along with their respective owners. Automating this process with a script can save a significant amount of time and effort. In this blog, I'll walk you through a PowerShell script that does just that—fetches the list of pages and their owners, and exports the data to an Excel file for easy management. Prerequisites Before diving into the script, ensure you have the following: PnP PowerShell Module : Install this module if you haven't already. You can do so by running: Install-Module -Name "PnP.PowerShell" Permissions : Ensure you have the necessary permissions to access the SharePoint site and its subsites. The PowerShell Script Below is the PowerShell script that retrieves the pages from the SharePoint site and it

Copying Footers Between SharePoint Sites Using PnP PowerShell

Recently, I have been extensively working with SharePoint and the Patterns and Practices (PnP) PowerShell module. PnP has significantly simplified various tasks by providing easy-to-use command sets and thorough documentation. One particular task that PnP has made straightforward is copying a footer from one SharePoint site to another. This process can be achieved with just a few commands. Why Use PnP PowerShell? PnP PowerShell is a set of cmdlets designed to work with SharePoint Online and SharePoint on-premises. It simplifies the management and automation of common tasks and provides commands for nearly every aspect of SharePoint administration. The PnP module is especially useful for tasks that would otherwise require complex scripting or manual intervention. Copying a Footer with PnP PowerShell To copy a footer from one SharePoint site to another, follow these steps. This process involves exporting the footer template from the source site in XML format and

New-PnPTenantSite: The remote server returned an error: (401) Unauthorized.

New-PnPTenantSite: The remote server returned an error: (401) Unauthorized. Recently I was working on automate SharePoint site provisioning PnP script. We wanted to schedule this script to auto trigger on hourly basis, so we scheduled the script. As the script was to be scheduled one, we started creating SharePoint Apps to manage authentication. Register SharePoint Add-ins Go to <site collection url>/_layouts/15/AppRegNew.aspx by using a web browser. AppRegNew page form Enter values for the follow form fields: Add-in ID . Also known as client ID; a GUID that can be generated (when you select Generate ) or pasted into AppRegNew.aspx. The value must be unique for each add-in and must be lowercase .   Add-in Secret . Also known as the client secret, an opaque string. It is generated on the AppRegNew.aspx page by using the Generate button. Title:  A user-friendly title: for example, Contoso photo print