Link to home
Start Free TrialLog in
Avatar of Alex
AlexFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Remove files with specific extension from folder

Good morning all,

OK so

There is a process our machines follow when they boot up, I need to remove an array of file types, thus I have the following script
$Files ='*.pdf','*.doc','*.dot','*.docx','*.docm','*.dotx','*.dotm','*.docb','*.xls','*.xlt','*.xlm','*.xltx','*.xlsm','*.xlsb','*.xla','*.pptx','*.pptm','*.potx','*.potm','*.ppsx','*.ppsm'

Remove-Item "c:\users\$env:UserName\appdata\roaming\Noname"


Get-ChildItem -Path 'c:\users\$env:UserName\appdata\roaming\Noname' $Files | foreach { Remove-Item -Path $_.FullName }

Open in new window


Doesn't work, nor can any amount of googling help :(

Could someone give me a hit in the right direction?

Thank you very much

Alex
ASKER CERTIFIED SOLUTION
Avatar of Shaun Hardneck
Shaun Hardneck
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alex

ASKER

Excellent, I nearly got there!