0
Receive-Job -Name updater >>C:\Users\d3\Documents\Batch\path\doc1.txt
clear-content "C:\Users\d3\Documents\Batch\path\doc1.txt"

ジョブ内の上記のコードは、doc1 内の複数の行を更新する場合があります。doc1 が更新された場合、更新されたエントリを取得する必要があります。

if(doc1 gets updated)
{
    get the updated entries alone in a variable
}
4

1 に答える 1

1

あなたのスクリプトは現在、ジョブの出力をやみくもに にパイプし、doc1その出力が何であるかを調べようとしています。あなたの質問から、実際に必要な doc1のか、それとも出力をキャプチャするためにそれを使用しようとしているだけなのかわかりません。

その代わりに、最初に結果をキャプチャするだけで、それを操作できます。

$lines = Receive-Job -Name updater
if ($lines.Count -ne 0)
{
    # send your email here if there are lines returned

    # push the output to the file, if you still need to
    $lines >> C:\Users\d3\Documents\Batch\path\doc1.txt
}
于 2013-05-22T09:46:03.353 に答える