Hi,
I have a script that collects data. I want it to run till I either kill it or until a certain amount of data is collected. I know there is something called measure-command. Does it have the ability to break when a certain amount of data is met?
Running a script for allotted amount of time or needed data.
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Running a script for allotted amount of time or needed data.
Ok how would I go about doing what I originally asked.
Re: Running a script for allotted amount of time or needed data.
How would i collect the data into a file. I tried the below but the file doesn't appear.
Code: Select all
start-job {gci c:\ -Recurse | Set-Content .\outtext.txt} | Wait-Job -Timeout 10
Re: Running a script for allotted amount of time or needed data.
Looking into it looks like it doesn't work. It creates the file but there is no data in file. Also reading about jobs the wait option brings back the terminal but job is still running.
Code: Select all
$job = Start-Job -ScriptBlock { Get-Process }
Receive-Job -Job $job | Out-File results.txt
Re: Running a script for allotted amount of time or needed data.
Code: Select all
$job = Start-Job -ScriptBlock { Get-Process }
$job | Wait-Job | Receive-Job | Out-File results.txt