Reputation: 19
Receive-Job -Name updater >>C:\Users\d3\Documents\Batch\path\doc1.txt
clear-content "C:\Users\d3\Documents\Batch\path\doc1.txt"
The above code in the job may update multiple lines in the doc1. If doc1 gets updated, I need to retrieve the updated entries.
if(doc1 gets updated)
{
get the updated entries alone in a variable
}
Upvotes: 0
Views: 104
Reputation: 34198
Your script is currently piping the output of the job blindly into doc1
, and then trying to work out what that output was. I'm not sure from your question whether you actually need doc1
or whether you're just trying to use that to capture the output.
Instead of that, simply capturing the result first, so you can work with it:
$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
}
Upvotes: 1