|
1 | 1 | function Expand-LSUpdate {
|
2 | 2 | <#
|
3 | 3 | .SYNOPSIS
|
4 |
| - Extracts a packages installer. |
| 4 | + Extracts package installers. |
5 | 5 |
|
6 | 6 | .DESCRIPTION
|
7 |
| - Extracts a packages installer. |
| 7 | + Extracts package installers. |
8 | 8 |
|
9 | 9 | .PARAMETER Package
|
10 |
| - The Lenovo package object to extract |
| 10 | + The Lenovo package or packages whose installer to extract |
11 | 11 |
|
12 | 12 | .PARAMETER Path
|
13 |
| - The directory containing the package files to extract. |
| 13 | + The directory containing the previously downloaded packages. |
| 14 | + Use `Save-LSUpdate` to download packages. |
14 | 15 | #>
|
15 | 16 | [CmdletBinding()]
|
16 | 17 | Param (
|
|
20 | 21 | [System.IO.DirectoryInfo]$Path = "$env:TEMP\LSUPackages"
|
21 | 22 | )
|
22 | 23 |
|
23 |
| - if ($Package.Installer.ExtractCommand) { |
24 |
| - Write-Verbose "Extracting package $($Package.ID) ..." |
25 |
| - $PackageDirectory = Join-Path -Path $Path -ChildPath $Package.ID |
26 |
| - $extractionProcess = Invoke-PackageCommand -Path $PackageDirectory -Command $Package.Installer.ExtractCommand -RuntimeLimit $script:LSUClientConfiguration.MaxExtractRuntime |
27 |
| - if ($extractionProcess.Err) { |
28 |
| - Write-Warning "Extraction of package $($Package.ID) has failed!" |
29 |
| - } elseif ($extractionProcess.Info.ExitCode -ne 0) { |
30 |
| - Write-Warning "Extraction of package $($Package.ID) may have failed!" |
| 24 | + begin { |
| 25 | + if ($PSBoundParameters['Debug'] -and $DebugPreference -eq 'Inquire') { |
| 26 | + Write-Verbose "Adjusting the DebugPreference to 'Continue'." |
| 27 | + $DebugPreference = 'Continue' |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + process { |
| 32 | + foreach ($PackageToExtract in $Package) { |
| 33 | + if ($PackageToExtract.Installer.ExtractCommand) { |
| 34 | + Write-Verbose "Extracting package $($PackageToExtract.ID) ..." |
| 35 | + $PackageDirectory = Join-Path -Path $Path -ChildPath $PackageToExtract.ID |
| 36 | + $extractionProcess = Invoke-PackageCommand -Path $PackageDirectory -Command $PackageToExtract.Installer.ExtractCommand -RuntimeLimit $script:LSUClientConfiguration.MaxExtractRuntime |
| 37 | + if ($extractionProcess.Err) { |
| 38 | + Write-Warning "Extraction of package $($PackageToExtract.ID) has failed!" |
| 39 | + } elseif ($extractionProcess.Info.ExitCode -ne 0) { |
| 40 | + Write-Warning "Extraction of package $($PackageToExtract.ID) may have failed!" |
| 41 | + } |
| 42 | + } else { |
| 43 | + Write-Verbose "The package '$($PackageToExtract.ID)' does not require extraction." |
| 44 | + } |
31 | 45 | }
|
32 |
| - } else { |
33 |
| - Write-Verbose "The package '$($Package.ID)' does not require extraction." |
34 | 46 | }
|
35 | 47 | }
|
0 commit comments