For powershell, the Get-ChildItem
method can be used with an -Include
parameter to filter the found files:
Get-ChildItem -Path C:\Temp -Include *.exe -File -Recurse
To delete the found files pipe them into a foreach
block or into Remote-Item
Get-ChildItem -Path C:\Temp -Include *.exe -File -Recurse | foreach { $_.Delete()}
# or
Get-ChildItem -Path C:\Temp -Include *.exe -File -Recurse | Remove-Item -Recurse