Last active
December 21, 2018 15:15
-
-
Save alevyinroc/6e4bed853f8615ed92e6809a75bd2e9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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