Skip to content

Commit

Permalink
Simplify selecting which ESD to download
Browse files Browse the repository at this point in the history
No need to pick newest manually, just sort the list by date.

Also builds a hash table of package's properties rather than just
looking for a string ending in '.pkg'
  • Loading branch information
theaquamarine committed Jun 15, 2019
1 parent e0d3a79 commit d2e5319
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Get-Bootcamp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ $sucatalog.plist.dict.dict.dict | Where-Object { $_.String -match "Bootcamp" } |
}
if ($bootcamplist.Length -gt 1) {
Write-warning "Found more than 1 supported Bootcamp ESD. Selecting newest based on posted date which may not always be correct"
$bootcamplist | ForEach-Object {
if ($_.date -gt $latestdate) {
$latestdate = $_.date
$download = $_.array.dict.string | Where-Object { $_ -match '.pkg' }
}
}
} else { $download = $bootcamplist.array.dict.string | Where-Object { $_ -match '.pkg' }}
}
$esd = $bootcamplist | Sort-Object -Property Date | Select-Object -Last 1
# Build a hash table of the package's properties from the XML
$package = $esd.array.dict.selectnodes('key') | ForEach-Object {@{$($_.'#text') = $($_.nextsibling.'#text')}}
$download = $package.URL

# Download the BootCamp ESD
Start-BitsTransfer -Source $download -Destination "$OutputDir\BootCampESD.pkg" -ErrorAction Stop
Expand Down Expand Up @@ -79,4 +77,4 @@ if ($Install) {
else { exit }

# Clean up
if ($KeepFiles) { exit } else { Remove-Item -Path "$OutputDir\*" -Recurse -Force -ErrorAction SilentlyContinue }
if ($KeepFiles) { exit } else { Remove-Item -Path "$OutputDir\*" -Recurse -Force -ErrorAction SilentlyContinue }

0 comments on commit d2e5319

Please sign in to comment.