Hello
Thank you for your question and reaching out.
Please try to run below PS script from SharePoint Powershell window.
#Observe the folder as item, and the item attribute is Folder (FileSystemObjectType -eq "Folder")
$Folders = Get-PnPListItem -List $List -PageSize 100 -Fields FileLeafRef | Where {$_.FileSystemObjectType -eq "Folder"}
--If the reply is helpful, please Upvote and Accept as answer--