我将使用不同输出格式的许多powershell句子。我只需要控制台应用程序中所有输出的数据很少(实际上是Windows应用程序),我想用linq聊聊数据,因为Trim将会非常有用。
任何想法,比如将输出传递给文本文件,并将linq与此文本文件一起使用,但这可能效果不佳。
例如 我如何使用linq或其他技巧来区分与这个小脚本中的任何窗口相关的输出
#
# Script.ps1
#
param( [string]$strComputer = ".")
Get-Process |
Where-Object {$_.MainWindowTitle -ne ""} |
Select-Object MainWindowTitle |
Out-String -stream
答案 0 :(得分:0)
基本上搜索工具涉及select-string cmdlet
由于很难说你想做什么,这里有一些样本
$results=Get-Process |
Where-Object {$_.MainWindowTitle -ne ""} |
Select-Object MainWindowTitle |
Out-String -stream
$results |select-string "notepad" #process containing the word notepad
$results |select-string "\d{2}" #process with 2 digits