Home > OS >  PowerShell: delete all files from a folder exclude xml files
PowerShell: delete all files from a folder exclude xml files

Time:12-15

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

Foldername: d:\apps\Que

Subfolders should not be deleted

Thanks

CodePudding user response:

Remove-Item supports native exclusion:

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

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

  • Related