Fixed code - V1.0!

This commit is contained in:
Erik Eckert 2023-08-10 13:19:12 -06:00
parent 561b44d4ee
commit 361ce147eb

View File

@ -26,42 +26,28 @@ do {
Write-Debug -Message ("Processing: $project_Name") -Debug
# $project.visits | foreach -Parallel {
# $pathExist = Test-Path $USING:OutputPathBase_Project -ErrorAction SilentlyContinue
# if (!($pathExist)) {
# New-Item -Path $USING:OutputPathBase_Project -ItemType Directory
# }
# if ($_) {
# $testURI = $_.pdf_link + '&auth_token=' + $USING:APIToken
# $Outfile = $USING:OutputPathBase_Project + '\' + $_.unique_id + ".pdf"
# Invoke-WebRequest -Uri $testURI -OutFile $Outfile -TimeoutSec 300
# }
# } -ThrottleLimit 5
foreach ($visit in $Project.visits) {
$pathExist = Test-Path $OutputPathBase_Project -ErrorAction SilentlyContinue
$project.visits | foreach -Parallel {
$pathExist = Test-Path $USING:OutputPathBase_Project -ErrorAction SilentlyContinue
if (!($pathExist)) {
New-Item -Path $OutputPathBase_Project -ItemType Directory
New-Item -Path $USING:OutputPathBase_Project -ItemType Directory
}
if ($visit) {
Write-Debug -Message ("Checking " + $visit.unique_id) -Debug
$testURI = $visit.pdf_link + '&auth_token=' + $APIToken
$Outfile = $OutputPathBase_Project + '\' + $visit.unique_id + ".pdf"
if ($_) {
Write-Debug -Message ("Checking " + $_.unique_id) -Debug
$testURI = $_.pdf_link + '&auth_token=' + $USING:APIToken
$Outfile = $USING:OutputPathBase_Project + '\' + $_.unique_id + ".pdf"
if (!(Test-Path $Outfile)) {
Write-Debug ("Saving file: "+ $Outfile) -Debug
Write-Debug ("Saving file: " + $Outfile) -Debug
Invoke-WebRequest -Uri $testURI -OutFile $Outfile
}
}
}
$page++
} -ThrottleLimit 5
}
$page++
}
} until (
$response.Content -eq $null
until (
$null -eq $response.Content
)