#get DPM install path $dpmsetup = "HKLM:\SOFTWARE\Microsoft\Microsoft Data Protection Manager\Setup" $dpminstallregkey = get-itemproperty $dpmsetup $installpath = $dpminstallregkey.installpath $path = $installpath + "\Volumes\Replica" cd $path function GetFolders($path) { $folders = Get-ChildItem "." foreach ($folder in $folders) { if (Test-path $folder.Name -pathtype Container) { Write-Host $folder.name -ForegroundColor Red GetCrashitems(".\"+$folder.Name) } } } function GetCrashItems($path) { $crashfile = "dpmra.crashdetect" $folders = Get-ChildItem $path foreach ($folder in $folders) { if (Test-path $folder.fullname -pathtype Container) { $items = Get-ChildItem $folder.fullname foreach($item in $items) { if ($item.name -match $crashfile) { Write-Host 'Deleting *dpmra.crashdetect file: '$item.fullname $item.delete() } } } } } GetFolders $path