Below you will find pages that utilize the taxonomy term “PnP PowerShell”
posts
Azure DevOps Spfx Deployment Workload Identity Federation
Introduction Thanks to Kinga Kazala for her timely article Deploy SPFx app using pipeline’s Workload Identity federation, which showcases how to use Workload Identity Federation to alleviate the need for using Entra app secrets or certificates. This method simplifies the setup process, especially when there’s reliance on a single person who might be unavailable.
We initially set up the SPFx pipeline for the Test environment using certificates with CLI for M365.
posts
Restoring Previous Versions of Items in a SharePoint List Using PnP PowerShell
When working with SharePoint lists, there might be times when you need to restore items to a previous version. Whether it’s due to an error, unwanted changes, or simply needing to revert to an earlier state, SharePoint’s versioning feature is a lifesaver. I used the script to undo bulk changes made by a Power Automate flow after the process failed halfway due to some data needing correction. For data integrity, the bulk update needed to be undone before running the Power Automate flow again after the data corrections were made.
posts
Get Drive ID and Drive Item ID for File for Further Microsoft Graph Operations using PnP PowerShell
Introduction When working with files in SharePoint, the drive ID and drive item ID are essential parameters for further manipulation using Microsoft Graph API. The drive ID is a base64 encoded string composed of the site ID, web ID, and list ID for a particular SharePoint library. For more details, refer to Microsoft Graph: Encoding and decoding the drive ID by Mikael Svenson. The item ID part appears to be a base32 encoding of the SharePoint item’s unique ID, though the exact mechanics are still being explored.
posts
Audit Service Principal Access to SharePoint Sites with Sites.Selected Permissions
Ensuring the security and compliance of your SharePoint environment is crucial, especially when dealing with service principals, Entra ID apps, or federated identities. These entities often have elevated permissions that, if mismanaged, can lead to unauthorized access and potential data breaches. Regularly auditing these permissions is a best practice for maintaining a secure and compliant SharePoint environment.
Application only or granular access to individual site instead of whole tenant, scope called “Sites.
posts
Optimizing PowerShell Scripts to check for unique permissions in SharePoint: REST API vs. Get-PnPListItem
When working with large SharePoint sites, checking for unique permissions can be a time-consuming task. This blog post explores methods to optimize PowerShell scripts for fetching property HasUniqueRoleAssignments to determine unique permissions, including using PnP PowerShell and the SharePoint REST API. We compare their performance and highlight the advantages and limitations of each approach.
Using PnP PowerShell PnP PowerShell provides an efficient way to interact with SharePoint Online and retrieve list items to check for unique permissions.
posts
Teamifying an Existing M365 Group with PowerShell
Teamifying an Existing M365 Group with PowerShell Within M365 , SharePoint and Teams together provides a rich collaboaration platform. When a team site is created from SharePoint admin centre, it is not associated with a Teams despite a M365 group is created in the background. To extend SharePoint collaboration features , there is a need to “teamify” an existing Microsoft 365 Group, essentially attaching a new Teams instance to it to allow use of channels and other apps.
posts
Counting Files and folders within SharePoint Libraries using PnP PowerShell
Counting Files and Folders within SharePoint Libraries using PnP PowerShell This post shows a PowerShell script using PnP PowerShell module to count the number of files and folders within a SharePoint library. It might be useful doing an inventory of file count.
$SiteURL = "Counting Files within a SharePoint Library using PnP PowerShell" # Generate a unique log file name using today's date $dateTime = (Get-Date).toString("dd-MM-yyyy") $invocation = (Get-Variable MyInvocation).Value $directorypath = Split-Path $invocation.
posts
Resolving the 'PnP PowerShell Not Digitally Signed' Issue
Resolving the ‘PnP PowerShell Not Digitally Signed’ Issue If you’ve recently upgraded PnP PowerShell to the latest nightly build and are encountering errors when trying to execute any PnP PowerShell cmdlets, this guide is for you.
PS C:\Users\RAuckloo> connect-pnponline -url https://contoso-admin.sharepoint.com -Interactive connect-pnponline: The 'connect-pnponline' command was found in the module 'PnP. PowerShell', but the module could not be loaded due to the following error: [Errors occurred while loading the format data file: \\contoso-it.
posts
Retrieving File Count and Size of a folder using PnP PowerShell
Retrieving File Count and Size of a folder within a SharePoint Library using PnP PowerShell This post covers a PowerShell script that uses the PnP PowerShell module to retrieve the file count and total size of a specific folder within a SharePoint library.
#Parameters $SiteURL = "https://contoso.sharepoint.com/sites/company311" $FolderSiteRelativeURL = "Shared Documents/Test1" #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Interactive #Get the folder $Folder = Get-PnPFolder -Url $FolderSiteRelativeURL -Includes ListItemAllFields #Get the total Size of the folder - with versions Write-host "Size of the Folder:" $([Math]::Round(($Folder.
posts
Retrieving SiteId from Microsoft Graph for Subsequent API Calls
Retrieving SiteId from Microsoft Graph for Subsequent API Calls This post offers an option to retrieve a SiteId from Microsoft Graph using PnP PowerShell. This can be particularly useful when making further API calls that require the SiteId.
$siteurl = "https://contoso.sharepoint.com/sites/Company311" Connect-PnPOnline -url $siteurl -interactive # for the site url https://contoso-admin.sharepoint.com/teams/app-m365 # Extract the domain and site name $uri = New-Object System.Uri($siteurl) $domain = $uri.Host $siteName = $uri.AbsolutePath # Construct the new URL $RestMethodUrl = "v1.
posts
Restrict certain SharePoint sites from tenant search and Copilot for M365 using PowerShell
Excluding certain SharePoint sites from search would mean the contents from the excluded sites won’t be available to M365 tenant search and Copilot for M365 using Restricted SharePoint Search feature.
The downsides using this feature are:
Limited Findability: By excluding certain SharePoint sites from search, you limit the findability of data. Users would need to know the specific sites where the data resides in order to search for it. This can hinder efficient data retrieval and records management.
posts
Managing Service Principal Permission Requests using PowerShell
Managing Service Principal Permission Requests using PowerShell Permission to the “SharePoint Online Client” service principal can be granted either in declarative method within SPFx solutions or directly. This post explores how to handle both declarative and direct permission grants using SPO PowerShell , ClI for M365 and PnP PowerShell.
PnP PowerShell Get all service principal permission grants Gets the collection of permission grants for the “SharePoint Online Client” service principal using the cmdlet Get-PnPTenantServicePrincipalPermissionGrants