I have some questions regarding Microsoft Edge and PowerShell.
When two Edge Windows with different Window Titles are open, I would like to specify one window title in PowerShell and use Stop-Process to close the window with that window title. The ps1 file code with the expected specifications is below.
$TargetTitle = "test"
$EdgeProcesses = (Get-Process -Name msedge)
foreach ($process in $EdgeProcesses) {
$title = $process.MainWindowTitle
if ($title -eq $TargetTitle) {
$id = $process.Id
Stop-Process -Id $id
}
}
When windows with titles A and B are open, and when you use the above code to specify the window with the title A and Stop-Process, it will include not only the window with the title A, but also all Edge windows, including the window of title B. The same thing happens even if Edge is opened in app mode.
It seems that Edge only generates one title group which includes all the windows. I think it's related with Edge’s multi-process architecture.
If you're trying to automate Edge, I suggest that you can use WebDriver.