Add Folders and Subfolders to SharePoint

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”

}

}

In the past, I have used RoboCopy to copy complete folders to SharePoint Document Libraries. Have you tried that?

You need to make sure you turn off version control first or you will need to check in all those files.

These would be new folders. No where to copy them from. Thanks for the reply!