I am trying to add many folders and subfolders to several SharePoint sites. I have this code that works but only adds folders and not subfolders. Any idea how to add the subfolders too?
Add folder structure to document library
Function AddFolders ( $DocLibName, $Folders )
{
Try
{
WriteLog “Adding folders to Document library : $DocLibName”
Foreach ( $Entry in $Folders )
{
# create the folder
$Folder = $Entry.Folder
$null = Add-PNPFolder -Name $Folder -Folder $DocLibName
WriteLog “Created folder: $Folder”
}
}
Catch
{
WriteError
WriteLog “ERROR: Adding folders to Document library : $DocLibName”
}
}