Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test-runtimes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
os: windows-latest
shell: powershell
version: '5.1'
- name: windows-powershell-7.0
- name: windows-powershell-7.4
os: windows-latest
shell: pwsh
version: '7.0'
version: '7.4'
- name: windows-powershell-7
os: windows-latest
shell: pwsh
Expand All @@ -49,12 +49,12 @@ jobs:
ref: ${{ inputs.ref }}

- name: Install minimum supported PowerShell
if: matrix.version == '7.0'
if: matrix.version == '7.4'
shell: pwsh
run: |
$Path = Join-Path -Path $env:RUNNER_TEMP -ChildPath "powershell-7.0.13"
$Path = Join-Path -Path $env:RUNNER_TEMP -ChildPath "powershell-7.4.0"
$Archive = "$Path.zip"
Invoke-WebRequest -Uri "https://github.com/PowerShell/PowerShell/releases/download/v7.0.13/PowerShell-7.0.13-win-x64.zip" -OutFile $Archive -ErrorAction Stop
Invoke-WebRequest -Uri "https://github.com/PowerShell/PowerShell/releases/download/v7.4.0/PowerShell-7.4.0-win-x64.zip" -OutFile $Archive -ErrorAction Stop
Expand-Archive -LiteralPath $Archive -DestinationPath $Path
$Path | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

Expand Down
2 changes: 1 addition & 1 deletion .rules/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
PSUseCompatibleSyntax = @{
Enable = $true
TargetVersions = @(
'7.0'
'7.4'
'5.1'
)
}
Expand Down
2 changes: 1 addition & 1 deletion .vscode/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
PSUseCompatibleSyntax = @{
TargetedVersions = @(
'7.0'
'7.4'
'6.0'
'5.1'
)
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

## VERSION

> [!WARNING]
> The module now requires Windows PowerShell 5.1 or PowerShell 7.4 or later on Windows, macOS, or Linux; PowerShell 4.0 or PowerShell 6/7.0-7.3 are no longer supported.

This version strengthens download and library reliability, improves validation and error reporting across public cmdlets, and refreshes help documentation.

- **Supported runtimes:** Raise the minimum supported PowerShell 7 version to 7.4 while retaining Windows PowerShell 5.1 support. Update the CI runtime matrix, syntax checks, test setup, and support documentation.
- **Downloads — `Save-EvergreenApp`:** Add optional `-VerifyChecksum` support for SHA-1, SHA-256, and SHA-512 hashes. Add bounded retries with exponential backoff and `Retry-After` handling, plus configurable connection and operation timeouts. Validate destination paths and filenames, support pipeline-bound paths, honor `-WhatIf` and custom user agents, publish only completed downloads, clean up partial files, and restore TLS settings.
- **App lookup and API queries — `Get-EvergreenApp`, `Find-EvergreenApp`, `Get-EvergreenAppFromApi`, `Get-EvergreenEndpointFromApi`:** Validate app names and API inputs, encode names for requests, preserve API error details, and reuse output filtering for local and API results. Improve literal-name matching and not-found diagnostics; clean up proxy and certificate state on completion or terminating errors. `Get-EvergreenApp` diagnostics now include exception and location details while preserving the original error.
- **Exports — `Export-EvergreenApp`, `Export-EvergreenManifest`:** Support pipeline input and improve validation and error reporting. `Export-EvergreenApp` batches pipeline records into a single write, respects `-WhatIf`, and preserves arrays, nested data, and nonstandard versions when merging and sorting.
- **Library operations — `Start-EvergreenLibraryUpdate`, `Get-EvergreenLibrary`, `Get-EvergreenAppFromLibrary`, `Remove-EvergreenLibraryAppVersion`:** Improve mixed-version sorting and isolate per-app state. Export only entries with matching installer files; stage manifest updates before deleting files; and reject unsafe paths and reparse points. Clarify pruning behavior and correct installer-path handling for retained entries.
- **Validation and compatibility — `Test-EvergreenApp`, `ConvertTo-DotNetVersionClass`, `Convert-Segment`, `Expand-CabArchive`:** Add HEAD-to-ranged-GET fallback, configurable timeouts, and HTTP status results to `Test-EvergreenApp`. Harden version conversion and make CAB extraction preserve original filenames and extensions. Support the insecure-redirect option on Windows PowerShell 5.1 while retaining compatibility checks for PowerShell Core.
- **Module initialization and help:** Handle GitHub rate limits and invalid cache versions in `Evergreen.psm1`; update `Import.ps1`; and refresh cmdlet and module help, including German, Spanish, French, and Japanese documentation.
- **Confirmation and preview — `Update-Evergreen`, `Remove-ProxyEnv`:** Add `-WhatIf` and `-Confirm` support. Guard the entire cache update before downloads or cache changes, and guard each proxy variable removal. Add regression coverage and document cache update confirmation behavior.
- **Analyzer compliance and compatibility:** Resolve configured PSScriptAnalyzer findings with targeted compatibility suppressions for platform-guarded code, naming and keyword corrections, and encoding fixes. Preserve default automatic date detection without a default-enabled switch parameter, and use Unicode escapes in CAB path validation.
- **Diagnostics — `Save-EvergreenApp`, `Update-Evergreen`:** Warn when retry-response status codes or `Retry-After` headers cannot be parsed, and route cache hash-validation failures through `Write-Message` with the appropriate message type.

## 2610.2862.0

Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Module version follows `YYmm.Build` (e.g., `2511.2826.0`). The `update-module.ym
## Code Conventions

- **One function per file**, filename must exactly match the function name (enforced by `Main.Tests.ps1`).
- Supports Windows PowerShell 5.1 and PowerShell 7.0+. Avoid PS6-only APIs.
- Supports Windows PowerShell 5.1 and PowerShell 7.4+. Avoid PS6-only APIs.
- PSScriptAnalyzer is run at `Error` and `Warning` severity. `PSAvoidUsingWriteHost` is excluded (use `Write-Message` instead).
- GitHub API calls check for `GITHUB_TOKEN` or `GH_TOKEN` environment variables to avoid rate limits.
- App functions are dot-sourced lazily (at invocation time, not module import) to reduce memory footprint.
Expand Down
1 change: 1 addition & 0 deletions Evergreen/Evergreen.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Evergreen script to initiate the module
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification = "Required for argument completion.")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "", Justification = "Not reachable on Ubuntu: Get-CimInstance")]
[CmdletBinding(SupportsShouldProcess = $false)]
param ()

Expand Down
6 changes: 3 additions & 3 deletions Evergreen/Private/ConvertFrom-Jwt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function ConvertFrom-Jwt {
}

# Helper: Convert Base64URL to Base64 and decode to JSON
function Decode-Part([System.String]$Part, [System.String]$Name) {
function Convert-Part ([System.String]$Part, [System.String]$Name) {
# Fix Base64URL encoding (replace - and _)
$replaced = $Part.Replace('-', '+').Replace('_', '/')
# Pad string length to multiple of 4
Expand All @@ -42,8 +42,8 @@ function ConvertFrom-Jwt {

# Return the decoded header and payload as a custom object
[PSCustomObject]@{
Header = Decode-Part -Part $parts[0] -Name "Header"
Payload = Decode-Part -Part $parts[1] -Name "Payload"
Header = Convert-Part -Part $parts[0] -Name "Header"
Payload = Convert-Part -Part $parts[1] -Name "Payload"
Signature = if ($parts.Count -gt 2) { $parts[2] } else { $null }
} | Write-Output
}
5 changes: 3 additions & 2 deletions Evergreen/Private/ConvertTo-DateTime.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ function ConvertTo-DateTime {
[System.String] $Pattern = "M/d/yyyy",

[Parameter()]
[System.Management.Automation.SwitchParameter] $AutoDetect = $true
[System.Management.Automation.SwitchParameter] $AutoDetect
)

Write-Verbose -Message "$($MyInvocation.MyCommand): Converting: [$DateTime]."
$Parsed = $false
if ($AutoDetect) {
$UseAutoDetect = -not $PSBoundParameters.ContainsKey('AutoDetect') -or $AutoDetect
if ($UseAutoDetect) {
[System.String[]] $KnownFormats = @(
"M/d/yyyy"
"MM/dd/yyyy HH:mm:ss"
Expand Down
3 changes: 2 additions & 1 deletion Evergreen/Private/Expand-CabArchive.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function Expand-CabArchive {
[CmdletBinding(SupportsShouldProcess = $false)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "", Justification = "Not reachable on Ubuntu: New-Object -ComObject")]
param (
[Parameter(Mandatory = $true, Position = 0)]
[ValidateNotNullOrEmpty()]
Expand Down Expand Up @@ -66,7 +67,7 @@ function Expand-CabArchive {
if ($Segment.IndexOfAny($InvalidCharacters) -ge 0 -or
$Segment -match '[<>:"/\\|?*\x00-\x1F]' -or
$Segment -match '[ .]$' -or
$Segment -match '^(CON|PRN|AUX|NUL|COM[1-9¹²³]|LPT[1-9¹²³])(?:\.|$)') {
$Segment -match '^(CON|PRN|AUX|NUL|COM[1-9\u00B9\u00B2\u00B3]|LPT[1-9\u00B9\u00B2\u00B3])(?:\.|$)') {
throw "CAB item path '$Name' contains an invalid file name."
}
}
Expand Down
2 changes: 1 addition & 1 deletion Evergreen/Private/Get-FilteredData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Get-FilteredData {
System.Object[] (an array of PSObjects or any objects with properties)

.OUTPUTS
System.Object[] — the subset of InputObject that match the provided filter configuration.
System.Object[] - the subset of InputObject that match the provided filter configuration.

.EXAMPLE
# filters.json (example)
Expand Down
1 change: 1 addition & 0 deletions Evergreen/Private/Get-FunctionResource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function Get-FunctionResource {
Reads an application manifest from JSON and returns a hashtable.
#>
[OutputType([System.Collections.IDictionary])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "", Justification = "Not reachable on PS5.1: ConvertFrom-Json -AsHashtable")]
[CmdletBinding(SupportsShouldProcess = $false)]
param (
[Parameter(Mandatory = $true, Position = 0)]
Expand Down
1 change: 1 addition & 0 deletions Evergreen/Private/Get-ModuleResource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function Get-ModuleResource {
Reads the module strings from the JSON file and returns a hashtable.
#>
[OutputType([System.Collections.IDictionary])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "", Justification = "Not reachable on PS5.1: ConvertFrom-Json -AsHashtable")]
[CmdletBinding(SupportsShouldProcess = $false)]
param (
[Parameter(Mandatory = $false, Position = 0)]
Expand Down
2 changes: 1 addition & 1 deletion Evergreen/Private/Invoke-EvergreenRestMethod.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function Invoke-EvergreenRestMethod {
$ErrorActionPreference = $ErrorAction
}
else {
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::continue
}

$SkipCertificateCheckEnabled = ($script:SkipCertificateCheck -eq $true -or $SkipCertificateCheck.IsPresent)
Expand Down
2 changes: 1 addition & 1 deletion Evergreen/Private/Invoke-EvergreenWebRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function Invoke-EvergreenWebRequest {

# Disable the Invoke-WebRequest progress bar for faster downloads
if ($PSBoundParameters.ContainsKey("Verbose")) {
$ProgressPreference = [System.Management.Automation.ActionPreference]::Continue
$ProgressPreference = [System.Management.Automation.ActionPreference]::continue
}
else {
$ProgressPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
Expand Down
8 changes: 7 additions & 1 deletion Evergreen/Private/Remove-ProxyEnv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ function Remove-ProxyEnv {
.DESCRIPTION
This function removes the Evergreen proxy server and credentials information
from the script-scoped environment variables.
Supports WhatIf and Confirm when removing each variable.
#>
[CmdletBinding(SupportsShouldProcess = $true)]
param ()

foreach ($VariableName in @("EvergreenProxy", "EvergreenProxyCreds")) {
if ($null -ne (Get-Variable -Name $VariableName -Scope "Script" -ErrorAction "SilentlyContinue")) {
Remove-Variable -Name $VariableName -Scope "Script" -Force -ErrorAction "Stop"
if ($PSCmdlet.ShouldProcess("Script-scoped variable '$VariableName'", "Remove proxy configuration")) {
Remove-Variable -Name $VariableName -Scope "Script" -Force -Confirm:$false -ErrorAction "Stop"
}
}
}
}
1 change: 1 addition & 0 deletions Evergreen/Private/Resolve-DnsNameWrapper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function Resolve-DnsNameWrapper {
Wrap DNS resolvers and return textual record data.
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseCompatibleCommands", "", Justification = "Not reachable on PS5.1: ConvertFrom-Json -AsHashtable")]
param (
[Parameter(Mandatory = $true, Position = 0)]
[ValidateNotNullOrEmpty()]
Expand Down
4 changes: 2 additions & 2 deletions Evergreen/Public/Save-EvergreenApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ function Save-EvergreenApp {
$statusCode = $null
$retryAfterHeader = $null
if ($null -ne $response) {
try { $statusCode = [System.Int32]$response.StatusCode } catch { }
try { $retryAfterHeader = [System.String]$response.Headers["Retry-After"] } catch { }
try { $statusCode = [System.Int32]$response.StatusCode } catch { Write-Warning -Message "Failed to parse status code from response." }
try { $retryAfterHeader = [System.String]$response.Headers["Retry-After"] } catch { Write-Warning -Message "Failed to parse Retry-After header from response." }
}

$retryableStatusCodes = @(408, 429, 500, 502, 503, 504)
Expand Down
30 changes: 19 additions & 11 deletions Evergreen/Public/Update-Evergreen.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function Update-Evergreen {
<#
.EXTERNALHELP Evergreen-help.xml
.EXTERNALHELP Evergreen-help.xml
#>
[CmdletBinding(SupportsShouldProcess = $false)]
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter()]
[System.Management.Automation.SwitchParameter] $Force,
Expand All @@ -20,8 +20,21 @@ function Update-Evergreen {
[System.String] $Release
)

# Validate Force parameter requirement when Release is specified
if ($PSBoundParameters['Release'] -and -not $PSBoundParameters['Force']) {
throw "-Force parameter required when specifying a release version."
}

$AppsPath = Get-EvergreenAppsPath
if (-not $PSCmdlet.ShouldProcess($AppsPath, "Download, validate, and synchronize Evergreen apps cache")) {
return
}

# Approval covers the entire cache operation, including nested commands.
$ConfirmPreference = [System.Management.Automation.ConfirmImpact]::None

# Account for changing the EVERGREEN_APPS_PATH variable at runtime
$Script:AppsPath = Get-EvergreenAppsPath
$Script:AppsPath = $AppsPath
$script:VersionFile = Join-Path -Path $script:AppsPath -ChildPath ".evergreen_version"
Write-Message -Message "Evergreen apps cache path: $($script:AppsPath)."

Expand All @@ -38,11 +51,6 @@ function Update-Evergreen {
$LocalVersion = $null
}

# Validate Force parameter requirement when Release is specified
if ($PSBoundParameters['Release'] -and -not $PSBoundParameters['Force']) {
throw "-Force parameter required when specifying a release version."
}

try {
# Get the latest version from the remote repository
if ($PSBoundParameters['Release']) {
Expand Down Expand Up @@ -190,7 +198,7 @@ function Update-Evergreen {
if (Test-Path -Path $ExtractPath) { Remove-Item -Path $ExtractPath -Recurse -Force -ErrorAction "SilentlyContinue" }
$global:ProgressPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue
Expand-Archive -Path $ZipFile -DestinationPath $ExtractPath -Force
$global:ProgressPreference = [System.Management.Automation.ActionPreference]::Continue
$global:ProgressPreference = [System.Management.Automation.ActionPreference]::continue
Remove-Item -Path $ZipFile -Force -ErrorAction "SilentlyContinue"

Write-Message -Message "Validating extracted files against SHA256 hashes."
Expand All @@ -200,15 +208,15 @@ function Update-Evergreen {
if (Test-Path -Path $FilePath) {
$LocalHash = (Get-FileHash -Path $FilePath -Algorithm "SHA256").Hash.ToLower()
if ($LocalHash -ne $File.sha256.ToLower()) {
Write-Warning -Message "SHA256 mismatch for file '$($File.file_path)'." -MessageType "Fail"
Write-Message -Message "SHA256 mismatch for file '$($File.file_path)'." -MessageType "Fail"
$DoReplace = $false
}
else {
Write-Verbose -Message "[$(Get-Symbol -Symbol "Tick")] File '$($File.file_path)' hash matches expected value."
}
}
else {
Write-Warning -Message "Expected file '$($File.file_path)' not found in extracted release." -MessageType "Fail"
Write-Message -Message "Expected file '$($File.file_path)' not found in extracted release." -MessageType "Fail"
$DoReplace = $false
}
}
Expand Down
Loading
Loading