I have a folder where I need to delete all files and folders except a small list of files and folders.
I can already exclude a list of files, but don\'t see a way to
According to MSDN Remove-Item has a known issue with the -exclude param. Use this variant instead.
Remove-Item
-exclude
Get-ChildItem * -exclude folderToExclude | Remove-Item