I need to remove the contents of a folder with powershell but keep a few files inside nested folders. I have tried witht he remove-item cmdlet but when i use the recurse switch, it ignores my excludes.. for example:
remove-item 'c:\inetpub\MySite\*' -exclude 'c:\inetput\MySite\app_config\connectionstring.config','c:\inetput\MySite\app_config\Include\appsettings.config' -recurse -force
So what I want to do is:
Remove contents in c:\inetpub\MySite,
except for:
c:\inetput\MySite\app_config\connectionstring.config
and
c:\inetput\MySite\app_config\Include\appsettings.config