Find processes that have open handles to your files – Powershell

This seemed like a really nice mix of handle.exe from sysinternals and powershell.

Check out the script at

Update fix for get-process piping

You have to remove the ‘.exe’ from the output from handle.exe to get it working to pipe it to gps.

param($fileFilter=$(throw “Filter must be specified”))
c:sysinthandle.exe $fileFilter | foreach {
    if ($_ -match ‘^(?<program>S*)s*pid: (?<pid>d*)s*(?<handle>[da-z]*):s*(?<file>(\)|([a-z]:).*)’) {
        $matches | select  @{n=”Path”;e={$_.file}},@{n=”Handle”;e={$_.handle}},@{n=”Pid”;e={$}},@{n=”ProcessName”;e={$_.Program.Replace(“.exe”,””)}}