# Script pour tester si le dossier mis en paramètre contient des dossiers vides # et si oui, les supprimer. # Source : https://stackoverflow.com/questions/28631419/how-to-recursively-remove-all-empty-folders-in-powershell Clear-Host Invoke-Command -ScriptBlock { $folder_to_check = "PATH_TO_FOLDER_CONTAINING_EMPTY_FOLDERS" $dirs = Get-ChildItem $folder_to_check -Directory -Recurse | Where-Object { (Get-ChildItem $_.fullName).count -eq 0 } | Select-Object -ExpandProperty FullName $dirs | Foreach-Object { Write-Host "Dossier qui sera supprimer car considéré comme vide : " $_ } # $dirs | Foreach-Object { Remove-Item $_ } }