Public/Get-OSDUpdateDownloads.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
<# .SYNOPSIS Downloads Current Microsoft Updates .DESCRIPTION Downloads Current Microsoft Updates Requires BITS for downloading the updates Requires Internet access for downloading the updates .LINK https://www.osdeploy.com/osdupdate/docs/functions/get-osdupdatedownloads .PARAMETER CatalogOffice The Microsoft Office Update Catalog selected for Updates .PARAMETER OfficeProfile Microsoft Office Update Type .PARAMETER OfficeSetupUpdatesPath This is the Updates directory in your Office installation source MSP files will be extracted from the DownloadsPath This directory should be cleared first .PARAMETER CatalogWindows The Microsoft Windows Update Catalog selected for Updates .PARAMETER WindowsBuild The Windows OS Build .PARAMETER WindowsProfile Microsoft Office Update Type .PARAMETER RepositoryRootPath Full Path of the OSDUpdate Repository .PARAMETER GridView Displays the results in GridView with -PassThru #> function Get-OSDUpdateDownloads { [CmdletBinding(DefaultParameterSetName = 'Office')] PARAM ( [Parameter( ParameterSetName = 'Office', Mandatory = $True)] [ValidateSet( 'Office 2010 32-Bit', 'Office 2010 64-Bit', 'Office 2013 32-Bit', 'Office 2013 64-Bit', 'Office 2016 32-Bit', 'Office 2016 64-Bit')] [string]$CatalogOffice, [Parameter( ParameterSetName = 'Office', Mandatory = $True)] [ValidateSet( 'Default', 'Proofing', 'Language', 'All')] [string]$OfficeProfile, [Parameter(ParameterSetName = 'Office')] [string]$OfficeSetupUpdatesPath, [Parameter( ParameterSetName = 'Windows', Mandatory = $True, Position = 0)] [ValidateSet( 'Windows 7 x86', 'Windows 7 x64', 'Windows 10 x86', 'Windows 10 x64', 'Windows Server 2012 R2 x64', 'Windows Server 2016 x64', 'Windows Server 2019 x64')] [string]$CatalogWindows, [Parameter (ParameterSetName = 'Windows')] [ValidateSet (1809,1803,1709,1703,1607,1511,1507)] [string]$WindowsBuild, [Parameter(ParameterSetName = 'Windows')] [ValidateSet('SSU Servicing Stack Update','LCU Latest Cumulative Update','DNCU DotNet Cumulative Update','AFPU Adobe Flash Player','DUSU Dynamic Update Setup Update','DUCU Dynamic Update Component Update')] [string]$WindowsProfile, [Parameter(Mandatory = $True)] [string]$RepositoryRootPath, [switch]$GridView ) #=================================================================================================== # Variables #=================================================================================================== $OSDUpdateDownloads = @() #=================================================================================================== # Repository #=================================================================================================== if ($CatalogOffice) { New-OSDUpdateRepository -RepositoryRootPath "$RepositoryRootPath" -Catalog $CatalogOffice $DownloadsPath = "$RepositoryRootPath\$CatalogOffice" } if ($CatalogWindows) { New-OSDUpdateRepository -RepositoryRootPath "$RepositoryRootPath" -Catalog $CatalogWindows $DownloadsPath = "$RepositoryRootPath\$CatalogWindows" } #=================================================================================================== # Catalogs #=================================================================================================== if ($CatalogOffice) { if ($OfficeProfile) { $OSDUpdateDownloads = Get-OSDUpdate -CatalogOffice $CatalogOffice -OfficeProfile $OfficeProfile } else { $OSDUpdateDownloads = Get-OSDUpdate -CatalogOffice $CatalogOffice } } if ($CatalogWindows) { $OSDUpdateDownloads = Get-OSDUpdate -CatalogWindows $CatalogWindows } #=================================================================================================== # Windows Build #=================================================================================================== if ($WindowsBuild -eq 1809) {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*RS5*" -or $_.Title -like "*1809*"}} if ($WindowsBuild -eq 1803) {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*RS4*" -or $_.Title -like "*1803*"}} if ($WindowsBuild -eq 1709) {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*RS3*" -or $_.Title -like "*1709*"}} if ($WindowsBuild -eq 1703) {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*RS2*" -or $_.Title -like "*1703*"}} if ($WindowsBuild -eq 1607) {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*RS1*" -or $_.Title -like "*1607*"}} if ($WindowsBuild -eq 1511) {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*TH2*" -or $_.Title -like "*1511*"}} if ($WindowsBuild -eq 1507) {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*TH1*" -or $_.Title -like "*1507*"}} #=================================================================================================== # Windows Profile #=================================================================================================== if ($WindowsProfile -eq 'SSU Servicing Stack Update') {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*ServicingStackUpdate*"}} if ($WindowsProfile -eq 'LCU Latest Cumulative Update') {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.Title -like "*Cumulative Update for Windows*"}} if ($WindowsProfile -eq 'DNCU DotNet Cumulative Update') {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*DotNet*"}} if ($WindowsProfile -eq 'AFPU Adobe Flash Player') {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.Title -like "*Adobe*"}} if ($WindowsProfile -eq 'DUSU Dynamic Update Setup Update') {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*SetupDU*"}} if ($WindowsProfile -eq 'DUCU Dynamic Update Component Update') {$OSDUpdateDownloads = $OSDUpdateDownloads | Where-Object {$_.LegacyName -like "*CriticalDU*" -or $_.LegacyName -like "*SafeOSDU*"}} #=================================================================================================== # GridView #=================================================================================================== if ($GridView.IsPresent) {$OSDUpdateDownloads = $OSDUpdateDownloads | Out-GridView -PassThru -Title "Select OSDUpdate Downloads"} #=================================================================================================== # Download #=================================================================================================== $OSDUpdateDownloads = $OSDUpdateDownloads | Sort-Object DateCreated if ($CatalogOffice) { foreach ($Update in $OSDUpdateDownloads) { $UpdateFile = $($Update.FileName) $MspFile = $UpdateFile -replace '.cab', '.msp' $DownloadDirectory = "$DownloadsPath\$($Update.Title)" if (!(Test-Path "$DownloadDirectory")) {New-Item -Path "$DownloadDirectory" -ItemType Directory -Force | Out-Null} if (Test-Path "$DownloadDirectory\$MspFile") { Write-Host "$($Update.Title)" -ForegroundColor Cyan Write-Host "$DownloadDirectory\$MspFile" -ForegroundColor DarkGray Write-Host "Update already downloaded" -ForegroundColor DarkGray } else { Write-Host "$($Update.Title)" -ForegroundColor Cyan Write-Host "$($Update.OriginUri)" -ForegroundColor DarkGray Write-Host "$DownloadDirectory\$UpdateFile" -ForegroundColor DarkGray Start-BitsTransfer -Source $($Update.OriginUri) -Destination "$DownloadDirectory\$UpdateFile" } if ((Test-Path "$DownloadDirectory\$UpdateFile") -and (!(Test-Path "$DownloadDirectory\$MspFile"))) { Write-Host "Expanding $MspFile from $DownloadDirectory\$UpdateFile" -ForegroundColor DarkGray expand "$DownloadDirectory\$UpdateFile" -F:* "$DownloadDirectory" | Out-Null } if ((Test-Path "$DownloadDirectory\$UpdateFile") -and (Test-Path "$DownloadDirectory\$MspFile")) { Write-Host "Removing $DownloadDirectory\$UpdateFile" -ForegroundColor DarkGray Remove-Item "$DownloadDirectory\$UpdateFile" -Force | Out-Null } #=================================================================================================== # Office Setup Updates #=================================================================================================== if ($OfficeSetupUpdatesPath) { if (!(Test-Path "$OfficeSetupUpdatesPath")) {New-Item -Path "$OfficeSetupUpdatesPath" -ItemType Directory -Force | Out-Null} Write-Host "Date Created: $($Update.DateCreated)" -ForegroundColor DarkGray Write-Host "Source: $DownloadDirectory\$MspFile" -ForegroundColor DarkGray Write-Host "Destination: $OfficeSetupUpdatesPath\$MspFile" -ForegroundColor DarkGray Copy-Item -Path "$DownloadDirectory\$MspFile" "$OfficeSetupUpdatesPath\$MspFile" -Force Write-Host "" } } } if ($CatalogWindows) { foreach ($Update in $OSDUpdateDownloads) { $UpdateFile = $($Update.FileName) $DownloadDirectory = "$DownloadsPath\$($Update.Title)" if (!(Test-Path "$DownloadDirectory")) {New-Item -Path "$DownloadDirectory" -ItemType Directory -Force | Out-Null} if (Test-Path "$DownloadDirectory\$UpdateFile") { Write-Host "$($Update.Title)" -ForegroundColor Cyan Write-Host "$DownloadDirectory\$UpdateFile" -ForegroundColor DarkGray Write-Host "Update already downloaded" -ForegroundColor DarkGray } else { Write-Host "$($Update.Title)" -ForegroundColor Cyan Write-Host "$($Update.OriginUri)" -ForegroundColor DarkGray Write-Host "$DownloadDirectory\$UpdateFile" -ForegroundColor DarkGray Start-BitsTransfer -Source $($Update.OriginUri) -Destination "$DownloadDirectory\$UpdateFile" } } } } |