###前提・実現したいこと
powershell の get-service
の結果を絞り込み、特定サービスごとのステータスを一覧したい。
以下のコマンドよりスマートな書き方があれば教えてください。
Linux で同様の作業をするときは grep -f svc.list
で対処しています。
###発生している問題・エラーメッセージ
コマンドが長くなりすぎて見づらい。
###試したこと
# 余計なサービスも表示される get-service
# Running していることも確認したい # Stopped か Running のどちらか一方だけの一覧は意味がない get-service | where { $_.status -eq "Stopped" }
# 横に長すぎる(余計な項目が引っかかる可能性がある) get-service | where { $_.name -match "hoge|fuga|piyo|moge..."}
# 一時ファイルは使いたくない get-service > svcs.txt get-content svcs.txt | select-string -pattern (get-content list.txt)
# 現状ベストの方法だが、記号が多いので powershell に慣れていない人は入力に手間取るだろう get-service | % { [string]::Join(" ", @($_.status, $_.name)) } | select-string -pattern (get-content list.txt)
###補足情報(言語/FW/ツール等のバージョンなど)
Powershell 3.0 の使用を想定しています。

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。