Thursday, December 11, 2014

How to recursively remove a file type under a folder using PowerShell?


The below PowerShell code will help you to recursively find the files from a folder and remove it

The second line will recursively make the files in folder not rad only


$checkoutLocation = "D:\Develop\VSS\Vb"
# Removed the file recursively
Get-ChildItem -Path $checkoutLocation -Filter *.scc -Recurse | Remove-Item -Force

# Makes file not read-only recursively
Get-ChildItem -Path $checkoutLocation -Recurse | ForEach-Object { if ($_.IsReadOnly) { $_.IsReadOnly = $false } }