Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
034b731
CI on PowerShell 7.6 LTS, pinned tools, dependency watch, start-up wa…
Nico77600 Nov 24, 2026
e4c687f
Transfer package origin checks, retention gate details, optional shar…
Nico77600 Nov 24, 2026
65e051d
PowerShell 7.6 required, Windows events and recorded overrides, journ…
Nico77600 Nov 25, 2026
7ffd939
Optional protection of files at rest, cleanup action, rights check in…
Nico77600 Nov 25, 2026
2d6d89b
Cleanup lists only proven finished rollbacks, key checks and certific…
Nico77600 Nov 25, 2026
5b96b34
Version 3.3.0: guides, security policy, changelog and pictures
Nico77600 Nov 25, 2026
633871f
Guide, security policy and changelog corrections; neutral names in ex…
Nico77600 Nov 25, 2026
14550ab
Tests remove their links, strip console colours, full action list
Nico77600 Nov 26, 2026
6aeeb00
Refused imports leave nothing behind; clearer proof, cleanup and even…
Nico77600 Nov 26, 2026
7bbf3eb
Import undo removes only unchanged extracted files; certificate warni…
Nico77600 Nov 26, 2026
4f33317
Printed next-phase commands keep the run's object selection
Nico77600 Nov 26, 2026
8bcac46
Packages carry the object selection; the console uses it and printed …
Nico77600 Nov 26, 2026
36d5d65
Selection is kept on the package's own batch, checked on read and ign…
Nico77600 Nov 26, 2026
cf1d0ad
Console applies a package selection only to the run it was made for
Nico77600 Nov 26, 2026
bab71cf
Marker rewrite reads JSON with dates kept as strings
Nico77600 Nov 26, 2026
5583759
CI: CodeQL action v4.39.5
Nico77600 Nov 26, 2026
40c7779
3.3.0: release date, lab validation note, pictures and guides
Nico77600 Nov 26, 2026
298924e
CI: matrix written as one JSON line
Nico77600 Nov 26, 2026
2b1438a
Marker rewrite: DateKind first, as the JSON guard expects
Nico77600 Nov 26, 2026
213b7ed
Exchange Online child starts from its script file under AllSigned; th…
Nico77600 Nov 27, 2026
21f47cc
Verify ExchangeOnlineManagement Microsoft signatures before child byp…
Nico77600 Nov 27, 2026
176d549
Write imported batch marker in GUI package import, guard only active …
Nico77600 Nov 28, 2026
de65196
PraRemoteMailbox 3.3.0: owner-signed runtime
Nico77600 Nov 28, 2026
77ae0dc
Keep LF line endings on checkout for CI and release tooling scripts i…
Nico77600 Nov 28, 2026
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
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,8 @@ package/docs/images/report-global-recover-light.png -text
package/docs/images/report-phase-light.png -text
package/docs/images/report-phase-warning-light.png -text
CHANGELOG.md -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol

# Repository CI and release tooling scripts keep LF line endings on checkout.
.github/scripts/*.ps1 text eol=lf
tools/New-Sbom.ps1 text eol=lf
tools/Compare-ReleaseSource.ps1 text eol=lf
42 changes: 42 additions & 0 deletions .github/ci-pins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"schema": 1,
"powerShell": [
{
"role": "primary",
"line": "7.6",
"version": "7.6.10",
"dotNetRuntime": "10.0.15",
"sha256": "7D871531806EB1646264E4BBABD9F0C30C23355591BC756BB9909448C29AE166",
"source": "https://github.com/PowerShell/PowerShell/releases/tag/v7.6.10",
"hashSource": "https://github.com/PowerShell/PowerShell/releases/download/v7.6.10/hashes.sha256",
"supportEnds": "2028-11-14",
"supportSource": "https://learn.microsoft.com/powershell/scripting/install/powershell-support-lifecycle"
}

],
"signingCertificate": {
"thumbprint": "0F28E442889F17B5F4D251E8F96E7CC6E2C9C6D6",
"notAfter": "2027-10-13",
"warnDays": 90
},
"modules": [
{
"name": "Pester",
"version": "6.1.0",
"sha256": "0207A75EA09F81B27C1DED44898B2BB3C845BAFA02045BD64A39E26A53CA41B4",
"sha512Base64": "GK3Db7arrcdZ4Z/i/VMptAzZccIpftsTOR1fgVlMETmSFZkbsD759KhlxGhlyolj0K9/7axmlFo5iozx3ikM0A==",
"size": 420319,
"source": "https://www.powershellgallery.com/packages/Pester/6.1.0",
"hashSource": "https://www.powershellgallery.com/api/v2/Packages(Id='Pester',Version='6.1.0')"
},
{
"name": "PSScriptAnalyzer",
"version": "1.25.0",
"sha256": "14E634C828EB98EFB9F40B2918BA90F139ED5ECCDF663A2A747736D996995D60",
"sha512Base64": "5/tXMmLmBLqymRSuYpIdJLl8L4i1GbQSd7QD72zhY/FLfRs23HNEmmjlrlqNlQKJGxDCZBMf0YE63ym/ExwWYw==",
"size": 14658674,
"source": "https://www.powershellgallery.com/packages/PSScriptAnalyzer/1.25.0",
"hashSource": "https://www.powershellgallery.com/api/v2/Packages(Id='PSScriptAnalyzer',Version='1.25.0')"
}
]
}
3 changes: 2 additions & 1 deletion .github/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"tests/PackageIntegrity.Tests.ps1",
"tests/PraReport.Tests.ps1",
"tests/PraLegacyFixtures.Tests.ps1",
"tests/PraDocumentation.Tests.ps1"
"tests/PraDocumentation.Tests.ps1",
"tests/PraRepository.Tests.ps1"
],
"packageBuilder": "tools/New-PraPackage.ps1",
"packageEntry": "Invoke-PraRemoteMailbox.ps1"
Expand Down
85 changes: 70 additions & 15 deletions .github/scripts/Initialize-CIModules.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,83 @@
#Requires -Version 5.1
<#
.SYNOPSIS
CI only. Installs the pinned analysis and test modules from the PowerShell Gallery packages, after checking their hashes.
.DESCRIPTION
.github\ci-pins.json holds, for each module, the version and the hash of its .nupkg together. The package of that exact version is downloaded,
its SHA-256 (and its SHA-512 as published by the Gallery) must equal the pins, and only then is it extracted under <Destination>\<Name>\<Version>.
A package that does not match is deleted and stops the step. The folder is put on PSModulePath of the next steps through GITHUB_ENV.
.PARAMETER Destination
The folder that receives <Name>\<Version> for each module.
.PARAMETER PinsPath
The pin file. Default: .github\ci-pins.json.
.PARAMETER PackageDirectory
A folder that already holds <Name>.<Version>.nupkg files; nothing is downloaded. The hashes are checked all the same.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)][string]$Destination
[Parameter(Mandatory)][string]$Destination,
[string]$PinsPath = (Join-Path $PSScriptRoot '..\ci-pins.json'),
[string]$PackageDirectory
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
[void][IO.Directory]::CreateDirectory($Destination)
Save-Module -Name Pester -RequiredVersion 6.1.0 -Repository PSGallery -Path $Destination -Force -ErrorAction Stop
Save-Module -Name PSScriptAnalyzer -RequiredVersion 1.25.0 -Repository PSGallery -Path $Destination -Force -ErrorAction Stop
Add-Type -AssemblyName System.IO.Compression.FileSystem

foreach ($module in @(
@{ Name = 'Pester'; Version = '6.1.0' },
@{ Name = 'PSScriptAnalyzer'; Version = '1.25.0' }
)) {
$manifest = Join-Path $Destination ('{0}\{1}\{0}.psd1' -f $module.Name, $module.Version)
if (-not (Test-Path -LiteralPath $manifest -PathType Leaf)) {
throw "The pinned module was not saved: $manifest"
function Assert-PackageHash {
param([Parameter(Mandatory)][string]$Path, [Parameter(Mandatory)]$Pin)
$sha256 = (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash
if (-not [string]::Equals($sha256, [string]$Pin.sha256, [StringComparison]::OrdinalIgnoreCase)) {
throw "The package of $($Pin.name) $($Pin.version) does not match its pinned SHA-256 ($sha256)."
}
$data = Import-PowerShellDataFile -LiteralPath $manifest
if ([string]$data.ModuleVersion -cne $module.Version) {
throw "The saved module version does not match: $manifest"
$algorithm = [Security.Cryptography.SHA512]::Create()
try { $sha512 = [Convert]::ToBase64String($algorithm.ComputeHash([IO.File]::ReadAllBytes($Path))) } finally { $algorithm.Dispose() }
if (-not [string]::Equals($sha512, [string]$Pin.sha512Base64, [StringComparison]::Ordinal)) {
throw "The package of $($Pin.name) $($Pin.version) does not match its pinned SHA-512 ($sha512)."
}
}

$pins = Get-Content -LiteralPath $PinsPath -Raw -Encoding UTF8 | ConvertFrom-Json
$destinationFull = [IO.Path]::GetFullPath($Destination)
[void][IO.Directory]::CreateDirectory($destinationFull)
$download = Join-Path ([IO.Path]::GetTempPath()) ('ci-modules-' + [guid]::NewGuid().ToString('N'))
[void][IO.Directory]::CreateDirectory($download)
try {
foreach ($pin in @($pins.modules)) {
if ([string]$pin.name -notmatch '\A[A-Za-z][A-Za-z0-9.]*\z' -or [string]$pin.version -notmatch '\A\d+\.\d+\.\d+\z') { throw 'A module pin has an invalid name or version.' }
if ([string]$pin.sha256 -notmatch '\A[0-9A-Fa-f]{64}\z' -or [string]$pin.sha512Base64 -notmatch '\A[A-Za-z0-9+/]{86}==\z') { throw "The hash pins of $($pin.name) are not valid." }
$file = ('{0}.{1}.nupkg' -f $pin.name, $pin.version)
if ($PackageDirectory) {
$package = Join-Path $PackageDirectory $file
if (-not (Test-Path -LiteralPath $package -PathType Leaf)) { throw "The package is missing: $package" }
}
else {
$package = Join-Path $download $file
Invoke-WebRequest -Uri ('https://www.powershellgallery.com/api/v2/package/{0}/{1}' -f $pin.name, $pin.version) -OutFile $package -UseBasicParsing
}
try { Assert-PackageHash -Path $package -Pin $pin }
catch {
if (-not $PackageDirectory) { Remove-Item -LiteralPath $package -Force -ErrorAction SilentlyContinue }
throw
}
$target = Join-Path $destinationFull ('{0}\{1}' -f $pin.name, $pin.version)
if (Test-Path -LiteralPath $target) { Remove-Item -LiteralPath $target -Recurse -Force }
[IO.Compression.ZipFile]::ExtractToDirectory($package, $target)
foreach ($packaging in @('_rels', 'package', '[Content_Types].xml', ('{0}.nuspec' -f $pin.name))) {
$item = Join-Path $target $packaging
if (Test-Path -LiteralPath $item) { Remove-Item -LiteralPath $item -Recurse -Force }
}
$manifest = Join-Path $target ('{0}.psd1' -f $pin.name)
if (-not (Test-Path -LiteralPath $manifest -PathType Leaf)) { throw "The pinned module was not extracted: $manifest" }
$data = Import-PowerShellDataFile -LiteralPath $manifest
if ([string]$data.ModuleVersion -cne [string]$pin.version) { throw "The extracted module version does not match: $manifest" }
Write-Output ('{0} {1} installed from a package that matches its pinned hashes.' -f $pin.name, $pin.version)
}
}
finally {
Remove-Item -LiteralPath $download -Recurse -Force -ErrorAction SilentlyContinue
}

if (-not $env:GITHUB_ENV) { throw 'The GitHub Actions environment file is missing.' }
'CI_MODULE_PATH={0}' -f [IO.Path]::GetFullPath($Destination) |
'CI_MODULE_PATH={0}' -f $destinationFull |
Out-File -LiteralPath $env:GITHUB_ENV -Encoding utf8 -Append
58 changes: 43 additions & 15 deletions .github/scripts/Install-PowerShell.ps1
Original file line number Diff line number Diff line change
@@ -1,23 +1,46 @@
#Requires -Version 5.1
<#
.SYNOPSIS
CI only. Makes sure that the pwsh used by the next steps is PowerShell 7.5 or later (the engine requires 7.5+).
CI only. Makes sure that the pwsh used by the next steps is exactly the pinned PowerShell release of the requested line.
.DESCRIPTION
The GitHub-hosted Windows images ship PowerShell 7.4. If pwsh on PATH is older than 7.5, the pinned release below is
downloaded from the official PowerShell release page, its SHA-256 is checked against the value pinned here (the same value
appears in the hashes.sha256 asset of the release), it is extracted under RUNNER_TEMP and put first on PATH for the
following steps. A full extracted copy keeps pwsh.exe inside $PSHOME, which the engine needs to start its child processes.
The GitHub-hosted Windows images ship an older PowerShell 7. Unless pwsh on PATH already is the pinned version, the pinned release is
downloaded from the official PowerShell release page, its SHA-256 is checked against the value pinned in .github\ci-pins.json (the same
value appears in the hashes.sha256 asset of the release), it is extracted under RUNNER_TEMP and put first on PATH for the following steps.
A full extracted copy keeps pwsh.exe inside $PSHOME, which the engine needs to start its child processes.
It does not connect to a lab or use publication credentials.
.PARAMETER Line
The PowerShell line to install, for example 7.6. The pinned version and hash of this line come from the pin file.
.PARAMETER PinsPath
The pin file. Default: .github\ci-pins.json.
.PARAMETER Version
Overrides the pinned version (with -Sha256).
.PARAMETER Sha256
Overrides the pinned SHA-256 (with -Version).
.PARAMETER ArchivePath
Uses this local archive instead of downloading it; it is checked against the pinned SHA-256 all the same.
#>
[CmdletBinding()]
param(
[string]$Version = '7.5.13',
[string]$Sha256 = '120B8F0B04F3B3F6E8C351DDBE568BF596CDCA15EEB2ECB7E724060051A36D65'
[string]$Line = '7.6',
[string]$PinsPath = (Join-Path $PSScriptRoot '..\ci-pins.json'),
[string]$Version,
[string]$Sha256,
[string]$ArchivePath
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$minimum = [version]'7.5.0'

if ([string]::IsNullOrWhiteSpace($Version) -ne [string]::IsNullOrWhiteSpace($Sha256)) { throw 'Give both -Version and -Sha256, or neither.' }
if ([string]::IsNullOrWhiteSpace($Version)) {
$pins = Get-Content -LiteralPath $PinsPath -Raw -Encoding UTF8 | ConvertFrom-Json
$pin = @($pins.powerShell | Where-Object { [string]::Equals([string]$_.line, $Line, [StringComparison]::OrdinalIgnoreCase) })
if ($pin.Count -ne 1) { throw "The pin file has no single PowerShell entry for the line $Line." }
$Version = [string]$pin[0].version
$Sha256 = [string]$pin[0].sha256
}
if ($Version -notmatch '\A\d+\.\d+\.\d+\z') { throw "The PowerShell version is not a release version: $Version" }
if ($Sha256 -notmatch '\A[0-9A-Fa-f]{64}\z') { throw 'The pinned SHA-256 is not 64 hexadecimal characters.' }

function Get-PwshVersion {
$command = Get-Command pwsh -ErrorAction SilentlyContinue
Expand All @@ -28,20 +51,25 @@ function Get-PwshVersion {
}

$current = Get-PwshVersion
if ($current -and $current -ge $minimum) {
Write-Output ('pwsh {0} already satisfies PowerShell 7.5+.' -f $current)
if ($current -and $current -eq [version]$Version) {
Write-Output ('pwsh {0} is the pinned version.' -f $current)
return
}

$runnerTemp = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { [IO.Path]::GetTempPath() }
$zip = Join-Path $runnerTemp ('PowerShell-{0}-win-x64.zip' -f $Version)
$destination = Join-Path $runnerTemp ('pwsh-{0}' -f $Version)
$uri = 'https://github.com/PowerShell/PowerShell/releases/download/v{0}/PowerShell-{0}-win-x64.zip' -f $Version
Invoke-WebRequest -Uri $uri -OutFile $zip -UseBasicParsing
if ($ArchivePath) {
$zip = $ArchivePath
}
else {
$zip = Join-Path $runnerTemp ('PowerShell-{0}-win-x64.zip' -f $Version)
$uri = 'https://github.com/PowerShell/PowerShell/releases/download/v{0}/PowerShell-{0}-win-x64.zip' -f $Version
Invoke-WebRequest -Uri $uri -OutFile $zip -UseBasicParsing
}
$actual = (Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash
if (-not [string]::Equals($actual, $Sha256, [StringComparison]::OrdinalIgnoreCase)) {
Remove-Item -LiteralPath $zip -Force
throw "The downloaded PowerShell archive does not match the pinned SHA-256 ($actual)."
if (-not $ArchivePath) { Remove-Item -LiteralPath $zip -Force }
throw "The PowerShell archive does not match the pinned SHA-256 ($actual)."
}
if (Test-Path -LiteralPath $destination) { throw "The destination already exists and will not be overwritten: $destination" }
Expand-Archive -LiteralPath $zip -DestinationPath $destination
Expand Down
33 changes: 29 additions & 4 deletions .github/scripts/Invoke-CI.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Requires -Version 7.5
#Requires -Version 7.6
[CmdletBinding()]
param(
[Parameter(Mandatory)][ValidateSet('Analyze', 'Test', 'Package')][string]$Stage,
Expand All @@ -10,6 +10,13 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$root = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..'))
$configuration = Get-Content -LiteralPath (Join-Path $root '.github\ci.json') -Raw | ConvertFrom-Json
$pins = Get-Content -LiteralPath (Join-Path $root '.github\ci-pins.json') -Raw | ConvertFrom-Json
function Get-PinnedModuleVersion {
param([Parameter(Mandatory)][string]$Name)
$pin = @($pins.modules | Where-Object { [string]::Equals([string]$_.name, $Name, [StringComparison]::OrdinalIgnoreCase) })
if ($pin.Count -ne 1) { throw "The pin file has no single entry for the module $Name." }
[string]$pin[0].version
}
$OutputDirectory = [IO.Path]::GetFullPath($OutputDirectory)
[void][IO.Directory]::CreateDirectory($OutputDirectory)

Expand All @@ -30,7 +37,7 @@ function Resolve-RepositoryFile {

switch ($Stage) {
'Analyze' {
Import-Module PSScriptAnalyzer -RequiredVersion 1.25.0 -Force -ErrorAction Stop
Import-Module PSScriptAnalyzer -RequiredVersion (Get-PinnedModuleVersion 'PSScriptAnalyzer') -Force -ErrorAction Stop
$tracked = @(git -C $root ls-files -- '*.ps1' '*.psm1' '*.psd1')
if ($LASTEXITCODE -ne 0) { throw 'Cannot enumerate the tracked PowerShell sources.' }
$runtime = [string]$configuration.runtimeRoot
Expand Down Expand Up @@ -65,7 +72,7 @@ switch ($Stage) {
ConvertTo-Json -InputObject $parseFailures -Depth 5 |
Out-File -LiteralPath (Join-Path $OutputDirectory 'syntax-errors.json') -Encoding utf8
$summary = [ordered]@{
Files = $files.Count; RuntimeFiles = $runtimeFiles.Count; TestAndToolFiles = $supportFiles.Count; Analyzer = '1.25.0'; SyntaxErrors = $parseFailures.Count
Files = $files.Count; RuntimeFiles = $runtimeFiles.Count; TestAndToolFiles = $supportFiles.Count; Analyzer = (Get-PinnedModuleVersion 'PSScriptAnalyzer'); SyntaxErrors = $parseFailures.Count
Errors = @($findings | Where-Object Severity -eq 'Error').Count
Warnings = @($findings | Where-Object Severity -eq 'Warning').Count
Informative = @($findings | Where-Object Severity -eq 'Information').Count
Expand All @@ -77,7 +84,7 @@ switch ($Stage) {
if ($parseFailures.Count) { throw 'PowerShell sources (runtime, tests or tools) contain syntax errors.' }
}
'Test' {
Import-Module Pester -RequiredVersion 6.1.0 -Force -ErrorAction Stop
Import-Module Pester -RequiredVersion (Get-PinnedModuleVersion 'Pester') -Force -ErrorAction Stop
if ($configuration.testMode -eq 'gate') {
$gate = Resolve-RepositoryFile $configuration.testEntry
$executable = Join-Path $PSHOME 'pwsh.exe'
Expand Down Expand Up @@ -142,5 +149,23 @@ switch ($Stage) {
ConvertTo-Json -InputObject $inventory -Depth 5 |
Out-File -LiteralPath (Join-Path $OutputDirectory 'package-inventory.json') -Encoding utf8
Write-Output ('Existing package builder completed: {0} files.' -f $files.Count)
# The bill of materials of the built package, written and checked the way a release does it (the ZIP itself is not kept).
Add-Type -AssemblyName System.IO.Compression.FileSystem
$sbomTool = Resolve-RepositoryFile 'tools/New-Sbom.ps1'
$zipFolder = Join-Path ([IO.Path]::GetTempPath()) ('ci-zip-' + [guid]::NewGuid().ToString('N'))
[void][IO.Directory]::CreateDirectory($zipFolder)
try {
$zipPath = Join-Path $zipFolder 'PraRemoteMailbox-ci.zip'
[IO.Compression.ZipFile]::CreateFromDirectory($destination, $zipPath, [IO.Compression.CompressionLevel]::Optimal, $true)
$written = @(& $sbomTool -PackageRoot $destination -ZipPath $zipPath -RepositoryRoot $root -OutputDirectory (Join-Path $OutputDirectory 'sbom') -Unsigned)
if ($written.Count -ne 2 -or @($written | Where-Object { -not (Test-Path -LiteralPath $_ -PathType Leaf) }).Count -gt 0) { throw 'The bill of materials and the dependency declaration were not both written.' }
$document = Get-Content -LiteralPath $written[0] -Raw -Encoding UTF8 | ConvertFrom-Json
$zipSha256 = (Get-FileHash -LiteralPath $zipPath -Algorithm SHA256).Hash.ToLowerInvariant()
$rootPackage = @($document.packages | Where-Object { $_.SPDXID -ceq 'SPDXRef-Package-PraRemoteMailbox' })
if ($rootPackage.Count -ne 1 -or $rootPackage[0].checksums[0].checksumValue -cne $zipSha256) { throw 'The bill of materials does not describe the ZIP that was built.' }
if (@($document.files).Count -ne $files.Count) { throw ('The bill of materials lists {0} files and the package holds {1}.' -f @($document.files).Count, $files.Count) }
Write-Output ('Bill of materials written and checked: {0} files, {1} packages.' -f @($document.files).Count, @($document.packages).Count)
}
finally { Remove-Item -LiteralPath $zipFolder -Recurse -Force -ErrorAction SilentlyContinue }
}
}
Loading