PowerShell で一部の文字列データの解析に問題があり、少し助けが必要です。基本的に、文字列データではなく、オブジェクトを出力しないアプリケーション コマンドがあります。
a = is the item I'm searching for
b = is the actual ouput from the command
c = replaces all the excess whitespace with a single space
d = is supposed to take $c "hostOSVersion 8.0.2 7-Mode" and just print "8.0.2 7-Mode"
ただし、$d は機能せず、$c と同じ値を出力するだけです。私は UNIX 派ですが、これは 1 つの awk ステートメントで簡単にできます。1 つのコマンドでこれを実行する方法を知っている場合は、それを行うか、以下の $d 構文の問題点を教えてください。
$a = "hostOSVersion"
$b = "hostOSVersion 8.0.2 7-Mode"
$c = ($a -replace "\s+", " ").Split(" ")
$d = ($y -replace "$a ", "")