I can get a list of current open windows like this:
Get-Process | where {$_.mainWindowTitle} | format-table mainWindowTitle
How do I write proper syntax to loop and check if Window Name exists and then exit?
Below is the logic I would like to execute:
# BASIC-esque CONDITIONAL LOGIC
# FILENAME: CheckWindowName.ps1
Get-Process | where {$_.mainWindowTitle} | format-table mainWindowTitle
# LOOP START - Loop through $_.mainWindowTitle / mainWindowTitle
If $_.mainWindowTitle CONTAINS "*notepad*" Then
Exit #break script
Else
Echo "Hello World! There are no instances of notepad open"
End If
# LOOP END