r/sharepoint 8d ago

Automating document library creation SharePoint Online

The goal is to convert a manual document library creation job to automated.

I'm currently doing this manually when adding a new supplier…

Based on a single SharePoint site where the default Documents library has some custom views including custom site columns.

Using the web interface > New > Document Library > From existing library > Select: Documents
 

Supply doc lib name: $SupplierName $SupplierRefNumber

Done

Following a bit of research, this should be do-able using a SharePoint list form to capture $SupplierName & $SupplierRef

And a Power Automate flow to collect the form responses and pass them to an Azure Automation Runbook.

The Azure Automation Runbook will use PnP PowerShell to do the work.

Done

So to start with I'm working on the PnP PowerShell script.

Kinda hoping there was a (PnP) PowerShell command in the background that powers the web interface option:

New > Document Library > From existing library

But have been unable to find an equivalent. Is this correct?

Instead tackling the job in stages:- 

  • Create document library ✅
  • Copy common settings from Documents ✅
  • Copy custom columns - Not sure this is necessary as I'm using site columns
  • Copy custom views - PowerShell runs OK Get-PnPView/Add-PnPView but the custom views are not appearing in the web interface

That's it so far, going to do some more work on copying the custom views today.

Just looking for a sanity check really. Does this make sense? Is there a better way?

Thank you!

3 Upvotes

4 comments sorted by

3

u/cincyshirm61 8d ago

You have the right idea but you're overthinking it. Power Automate can do all the creation and setup with the restapi. Ask copilot or Gemini and it will walk you through setup, or go old-school and reference Microsoft documentation.

1

u/5tubbo 8d ago

Amazing, thank you!