Public/Update-OSDoffice.ps1
<# .SYNOPSIS Downloads Microsoft Office Updates for the installation Updates directory .DESCRIPTION Downloads Microsoft Office Updates for the installation Updates directory Requires BITS for downloading the updates Requires Internet access for downloading the updates .LINK https://www.osdeploy.com/osdupdate/docs/functions/update-osdoffice .PARAMETER OfficeVersion The version of Microsoft Office .PARAMETER Selection The types of Updates to download .PARAMETER DownloadPath This is the path to download the updates initially. This should be a repository .PARAMETER OfficeUpdatesPath This is the Updates directory in your Office 2016 installation source. MSP files will be extracted from the DownloadPath .EXAMPLE Update-OSDoffice -OfficeVersion "Office 2016 64-Bit" -Selection Default -DownloadPath "C:\Software\Office Updates" -OfficeUpdatesPath "C:\Software\Office 2016 64-Bit\updates" Selects updates for Office 2016 64-Bit Downloads the Update CABs to "C:\Software\Office Updates" Extracts the MSP files to "C:\Software\Office 2016 64-Bit\updates" #> function Update-OSDoffice { [CmdletBinding()] PARAM ( [Parameter(Mandatory)] [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]$OfficeVersion, [Parameter(Mandatory)] [ValidateSet('Default','Full','en-us','Proofing','Languages')] [string]$Selection, [string]$DownloadPath, [string]$OfficeUpdatesPath ) Write-Warning "Updates are Current as of February 16, 2019" $AllOfficeUpdates = @() #=================================================================================================== # Catalogs #=================================================================================================== if ($OfficeVersion -eq 'Office 2010 32-Bit') { $AllOfficeUpdates = Import-Clixml -Path "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\OSDUpdate Office 2010.xml" $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.Title -like "*32-Bit*"} } if ($OfficeVersion -eq 'Office 2010 64-Bit') { $AllOfficeUpdates = Import-Clixml -Path "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\OSDUpdate Office 2010.xml" $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.Title -like "*64-Bit*"} } if ($OfficeVersion -eq 'Office 2013 32-Bit') { $AllOfficeUpdates = Import-Clixml -Path "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\OSDUpdate Office 2013.xml" $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.Title -like "*32-Bit*"} } if ($OfficeVersion -eq 'Office 2013 64-Bit') { $AllOfficeUpdates = Import-Clixml -Path "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\OSDUpdate Office 2013.xml" $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.Title -like "*64-Bit*"} } if ($OfficeVersion -eq 'Office 2016 32-Bit') { $AllOfficeUpdates = Import-Clixml -Path "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\OSDUpdate Office 2016.xml" $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.Title -like "*32-Bit*"} } if ($OfficeVersion -eq 'Office 2016 64-Bit') { $AllOfficeUpdates = Import-Clixml -Path "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\OSDUpdate Office 2016.xml" $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.Title -like "*64-Bit*"} } #=================================================================================================== # Standard Filters #=================================================================================================== $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.FileName -notlike "*Sharepoint*"} #=================================================================================================== # Selection #=================================================================================================== if ($Selection -eq 'Default') { $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.FileName -like "*none*" -or $_.FileName -like "*en-us*"} $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.Title -notlike "*Language Pack*"} } if ($Selection -eq 'en-us') { $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.FileName -like "*en-us*"} } if ($Selection -eq 'Languages') { $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.FileName -notlike "*none*" -and $_.FileName -notlike "*en-us*"} } if ($Selection -eq 'Proofing') { $AllOfficeUpdates = $AllOfficeUpdates | Where-Object {$_.FileName -like "*Proof*"} } #=================================================================================================== # Sorting #=================================================================================================== #$AllOfficeUpdates = $AllOfficeUpdates | Sort-Object [datetime]DateCreated | Sort-Object FileName -Unique #=================================================================================================== # Select Updates #=================================================================================================== #$AllOfficeUpdates = $AllOfficeUpdates | Sort-Object [datetime]DateCreated -Descending | Out-GridView -PassThru -Title "Select Office Updates" #$AllOfficeUpdates = $AllOfficeUpdates | Sort-Object OriginUri -Unique $AllOfficeUpdates = $AllOfficeUpdates | Sort-Object OriginUri -Unique Write-Host "Displaying $Selection Updates" -ForegroundColor Cyan $AllOfficeUpdates = $AllOfficeUpdates | Out-GridView -PassThru -Title "Select Office Updates" #=================================================================================================== # Download #=================================================================================================== if ($DownloadPath) { if (!(Test-Path "$DownloadPath")) {New-Item -Path "$DownloadPath" -ItemType Directory -Force | Out-Null} $AllOfficeUpdates = $AllOfficeUpdates | Sort-Object DateCreated foreach ($Update in $AllOfficeUpdates) { $DownloadDirectory = "$DownloadPath\$($Update.Title)" $CabFile = $($Update.FileName) if (!(Test-Path "$DownloadDirectory")) {New-Item -Path "$DownloadDirectory" -ItemType Directory -Force | Out-Null} if (Test-Path "$DownloadDirectory\$CabFile") { Write-Host "$($Update.Title)" -ForegroundColor Cyan Write-Host "$DownloadDirectory\$CabFile" -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\$CabFile" -ForegroundColor DarkGray Start-BitsTransfer -Source $($Update.OriginUri) -Destination "$DownloadDirectory\$CabFile" } #=================================================================================================== # Update Office Sources #=================================================================================================== if ($OfficeUpdatesPath) { if (!(Test-Path "$OfficeUpdatesPath")) {New-Item -Path "$OfficeUpdatesPath" -ItemType Directory -Force | Out-Null} Write-Host "Date Created: $($Update.DateCreated)" -ForegroundColor DarkGray if (Test-Path "$DownloadDirectory\$CabFile") { Write-Host "Expanding MSP" -ForegroundColor DarkGray expand "$DownloadDirectory\$CabFile" -F:* "$DownloadDirectory" | Out-Null } $MspFile = Get-ChildItem "$DownloadDirectory" *.msp | Select-Object -Property BaseName, Name, FullName foreach ($Msp in $MspFile) { Write-Host "Source: $($Msp.FullName)" -ForegroundColor DarkGray Write-Host "Destination: $OfficeUpdatesPath\$($Msp.Name)" -ForegroundColor DarkGray Copy-Item -Path "$($Msp.FullName)" "$OfficeUpdatesPath\$($Msp.Name)" -Force Write-Host "" } } } } #Return $AllOfficeUpdates } |