Hello all. I have a powershell script that works great for adding folders to sharepoint but I cant get it to add subfolders. I have many folders and subfolders I need to add to a large amount of sharepoint sites. Here is the code that works for flat folders and no subfolders. Any ideas.
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”
}
}