Skip to content

Instantly share code, notes, and snippets.

@alevyinroc
Last active December 21, 2018 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alevyinroc/6e4bed853f8615ed92e6809a75bd2e9a to your computer and use it in GitHub Desktop.
Save alevyinroc/6e4bed853f8615ed92e6809a75bd2e9a to your computer and use it in GitHub Desktop.
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$JobNum.zip";
Write-PSFMessage -Message "Preparing to download with job $JobNum";
Start-Sleep -Seconds (get-random -Minimum 1 -Maximum 5);
Invoke-WebRequest -uri "https://github.com/proxb/PoshRSJob/archive/master.zip" -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