Confirm the window exists
Task Manager shows the process and the window count even when nothing is visible. A process with a main window handle is running, but its window is off screen.
Get-Process | Where-Object MainWindowTitle | Select-Object Name,Id,MainWindowTitle
Get-Process notepad | Select-Object Id,MainWindowHandle,Responding