【发布时间】:2015-03-25 01:00:23
【问题描述】:
我可以像这样获取当前打开的窗口列表:
Get-Process | where {$_.mainWindowTitle} | format-table mainWindowTitle
如何编写正确的语法来循环并检查窗口名称是否存在然后退出?
下面是我要执行的逻辑:
# 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
【问题讨论】:
标签: powershell foreach powershell-4.0