Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import-module poshrsjob, PSFramework;
$DownloadDir = "e:\tmp\poshrsjob";
$MaxJobs = 3;
$LogFile = Join-Path -path $DownloadDir -ChildPath "Demo-$(Get-date -f 'yyyyMMddHHmmss').txt";
#Set-PSFLoggingProvider -name logfile -Enabled $true -filepath $LogFile;
Set-PSFLoggingProvider -name filesystem -Enabled $true -logpath $DownloadDir;
foreach ($i in 1..6) {
Start-RSJob -Throttle $MaxJobs -Batch "Demo" -argumentlist $i, $DownloadDir -ModulesToImport PSFramework -ScriptBlock {
param($JobNum, $OutputDir)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
$OutputFile = Join-Path -Path $OutputDir -ChildPath "RSJob$";
Write-PSFMessage -Message "Preparing to download with job $JobNum";
Start-Sleep -Seconds (get-random -Minimum 1 -Maximum 5);
Invoke-WebRequest -uri "" -OutFile $OutputFile;
Write-PSFMessage -Message "Download $JobNum complete";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment