Public/Get-WindowByTitle.ps1
function Get-WindowByTitle($WindowTitle = "*") { Write-Verbose "WindowTitle is: $WindowTitle" if ($WindowTitle -eq "*") { Write-Verbose "WindowTitle is *, return title of all processes" return Get-Process | Where-Object { $_.MainWindowTitle } | Select-Object Id, Name, MainWindowHandle, MainWindowTitle } else { Write-Verbose "WindowTitle is $WindowTitle, return title from this window" return Get-Process | Where-Object { $_.MainWindowTitle -like "*$WindowTitle*" } | Select-Object Id, Name, MainWindowHandle, MainWindowTitle } } |