Skip to content
Rishan Solutions
Rishan Solutions
  • PowerApps
  • SharePoint online
  • PowerAutomate
  • Python
  • AI
Rishan Solutions
Latest Posts
  • Taj Mahal, India February 22, 2026
  • How Generative AI Is Transforming Business Automation in 2026: From Task Bots to Autonomous Workflows February 11, 2026
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025 June 24, 2025
  • Recursive Queries in T-SQL May 7, 2025
  • Generating Test Data with CROSS JOIN May 7, 2025
  • Working with Hierarchical Data May 7, 2025

Managing SharePoint Online Document Set Workflows using PnP PowerShell

Posted on March 21, 2025March 21, 2025 by Rishan Solutions

Document Sets in SharePoint Online allow you to manage related documents as a single unit. Using PnP PowerShell, we can:

Automate document set creation
Configure metadata and permissions
Manage workflows for document approvals


Step 1: Connect to SharePoint Online

Connect to your SharePoint Online site using PnP PowerShell:

$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSite"
Connect-PnPOnline -Url $siteUrl -Interactive
Write-Host " Connected to SharePoint Online"

✔ Establishes a secure connection.


Step 2: Create a Document Set Content Type

Before using document sets, create a content type:

$docSetName = "ProjectFiles"
$groupName = "Custom Content Types"

Add-PnPContentType -Name $docSetName -Description "Document Set for Projects" -Group $groupName -ParentContentType "Document Set"
Write-Host " Document Set Content Type '$docSetName' created"

✔ Ensures structured document management.


Step 3: Add the Document Set to a Library

Apply the document set content type to a library:

$libraryName = "Project Documents"
Add-PnPContentTypeToList -List $libraryName -ContentType $docSetName
Write-Host " Document Set added to '$libraryName'"

✔ Enables document set functionality in a library.


Step 4: Automate Document Set Creation

Create a document set programmatically:

$docSetTitle = "Project A"
$libraryUrl = "Project Documents"

New-PnPListItem -List $libraryUrl -ContentType $docSetName -Values @{"Title" = $docSetTitle}
Write-Host " Document Set '$docSetTitle' created"

✔ Automates document set generation.


Step 5: Assign Metadata and Permissions

Set metadata and unique permissions for a document set:

$docSetItem = Get-PnPListItem -List $libraryUrl -Query "<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>$docSetTitle</Value></Eq></Where></Query></View>"

Set-PnPListItem -List $libraryUrl -Identity $docSetItem.Id -Values @{"ProjectStatus"="Active"}
Set-PnPListItemPermission -List $libraryUrl -Identity $docSetItem.Id -User "user@domain.com" -AddRole "Contribute"
Write-Host " Metadata and permissions assigned"

✔ Ensures data consistency and security.


Step 6: Automate Approval Workflows

Trigger Power Automate workflows using PnP PowerShell:

$flowName = "ApproveProjectDocuments"
Start-PnPFlow -List $libraryUrl -FlowName $flowName -Parameters @{"DocumentSetTitle"=$docSetTitle}
Write-Host " Workflow triggered for approval"

✔ Integrates Power Automate for approvals.


Step 7: Monitor and Manage Workflows

Check workflow status:

Get-PnPFlowRun -List $libraryUrl -FlowName $flowName | Select-Object Status, Started

✔ Provides real-time workflow tracking.


Step 8: Automate Cleanup of Completed Workflows

Remove completed workflows to optimize performance:

Remove-PnPFlowRun -List $libraryUrl -FlowName $flowName -RunId "workflow-run-id"
Write-Host " Cleaned up completed workflow runs"

✔ Ensures efficient workflow execution.

Posted Under PNP PowerShellApprovals Document Sets Metadata Permissions PNP PowerShell Power AUtomate SharePoint online Workflows

Post navigation

Java Deep Learning with Keras
Java-based AI Game Development

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Taj Mahal, India
  • How Generative AI Is Transforming Business Automation in 2026: From Task Bots to Autonomous Workflows
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025
  • Recursive Queries in T-SQL
  • Generating Test Data with CROSS JOIN

Recent Comments

  1. Michael Francis on Search , Filter and Lookup in power apps
  2. A WordPress Commenter on Hello world!

Archives

  • February 2026
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • January 2022

Categories

  • Active Directory
  • AI
  • AngularJS
  • Blockchain
  • Button
  • Buttons
  • Choice Column
  • Cloud
  • Cloud Computing
  • Data Science
  • Distribution List
  • DotNet
  • Dynamics365
  • Excel Desktop
  • Extended Reality (XR) – AR, VR, MR
  • Gallery
  • Icons
  • IoT
  • Java
  • Java Script
  • jQuery
  • Microsoft Teams
  • ML
  • MS Excel
  • MS Office 365
  • MS Word
  • Office 365
  • Outlook
  • PDF File
  • PNP PowerShell
  • Power BI
  • Power Pages
  • Power Platform
  • Power Virtual Agent
  • PowerApps
  • PowerAutomate
  • PowerPoint Desktop
  • PVA
  • Python
  • Quantum Computing
  • Radio button
  • ReactJS
  • Security Groups
  • SharePoint Document library
  • SharePoint online
  • SharePoint onpremise
  • SQL
  • SQL Server
  • Template
  • Uncategorized
  • Variable
  • Visio
  • Visual Studio code
  • Windows
© Rishan Solutions 2026 | Designed by PixaHive.com.
  • Rishan Solutions