Add-Type @" using System; using System.Runtime.InteropServices; using System.Text; public class E { [DllImport("user32.dll")] public static extern bool EnumWindows(D cb, IntPtr p); [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr h); [DllImport("user32.dll")] public static extern int GetWindowText(IntPtr h, StringBuilder s, int n); [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr h, out uint pid); public delegate bool D(IntPtr h, IntPtr p); } "@ $rows=@() $cb=[E+D]{ param($h,$p) if([E]::IsWindowVisible($h)){ $sb=New-Object System.Text.StringBuilder 256 [void][E]::GetWindowText($h,$sb,256) $t=$sb.ToString() $wp=0; [void][E]::GetWindowThreadProcessId($h,[ref]$wp) $pn=""; try{$pn=(Get-Process -Id $wp -EA Stop).ProcessName}catch{} $script:rows+=[pscustomobject]@{Hwnd=[long]$h;Ppid=$wp;Proc=$pn;Title=$t} }; return $true } [void][E]::EnumWindows($cb,[IntPtr]::Zero) $rows | Where-Object {$_.Proc -like "*btl4*"} | Format-Table -Auto | Out-String | Write-Host