How to use Add-PnPFolder to add a folder to other SPO Libraries

Callistus Lucien 0 Reputation points
2025-04-24T02:16:02.9366667+00:00

I can use Add-PnPFolder to add a folder to the Shared Documents library but receives the follow error message "Add-PnPFolder : File Not Found." when attempting to add a folder to any other document library.

I have a csv file with a list of libraries that I want to add a specific folder to:

ForEach($row in $csv)

{

Write-Host -f Yellow "Adding" $row.Folder "to" $row.Library

   # Add-PnPFolder -Name $row.Folder -Folder $row.Library

}

Error:
Add-PnPFolder : File Not Found.

At line:1 char:9

  •     Add-PnPFolder -Name $row.Library -Folder $row.Folder
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [Add-PnPFolder], PSInvalidOperationException
    • FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Files.AddFolder

Works just fine!! No errors.
ForEach($row in $csv)

{

Write-Host -f Yellow "Adding" $row.Folder "to" $row.Library

   Add-PnPFolder -Name $row.Folder -Folder "Shared Documents"

}

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,915 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.