Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PowerShell: delete all files from a folder exclude xml files

I need a powershell line to delete all files in a folder excluding xml files.

Foldername:
d:\apps\Que

Subfolders should not be deleted

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks

>Solution :

Remove-Item supports native exclusion:

Remove-Item "d:\apps\Que" -Exclude *.xml

use -WhatIf to check what would be deleted without actually deleting it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading