diff --git a/.gitattributes b/.gitattributes index aa4847f..87340bb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,6 +21,7 @@ package/PackageIntegrity.psd1 -text whitespace=blank-at-eol,space-before-tab,bla # Stable hashed files (SHA256 in the signed manifest) and the distribution copy of the changelog. package/module/PRA.Gui.xaml -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol package/templates/Report.template.html -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol +package/templates/GlobalReport.template.html -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol package/config/Targets.sample.csv -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol package/config/SharedPermissions.sample.csv -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol package/README.md -text whitespace=blank-at-eol,space-before-tab,blank-at-eof,cr-at-eol diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3ee96b..acda216 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: validate: name: Validate (${{ matrix.engine }}) runs-on: windows-2022 - timeout-minutes: 75 + timeout-minutes: 150 strategy: fail-fast: false matrix: diff --git a/CHANGELOG.md b/CHANGELOG.md index e07776f..3811452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes of PRA Remote Mailbox. Author: Nicolas Fabert. Versions foll a MAJOR version changes the command line or the configuration file, a MINOR version adds a feature, a PATCH version fixes a defect. The backup formats have their own version (see the guide, annex D). +## 3.2.0 — 2026-11-22 + +### Added +- Batches of thousands of objects: planned, measured and documented for 5,000 objects per batch. +- Retention check before a Recover: it stops when a cloud mailbox is not held by the retention policy. `-AcceptRetentionRisk` (a checkbox in the console) accepts the risk for one run; `Retention.CheckBeforeRecover` turns the check off; on two servers the cloud server writes a retention proof that the AD server accepts for `Retention.ProofMaxAgeHours` hours. +- Cloud accounts are confirmed against Active Directory before any cloud write (`Cloud.IdentityCheck`); the cloud part now reads Microsoft Graph for every object, so `User.Read.All` is needed for every run. +- Throttled or unavailable Microsoft Graph and Exchange Online reads are retried with a budget per object and per run (`Cloud.RetryBudgetObjectSeconds`, `Cloud.RetryBudgetRunMinutes`). +- Console: **To do** and **Finished** sections in the batch lists, the retention checkbox and proof line on Recover, Ctrl+C in the terminal no longer stops the window, and the activity log keeps its last 2,000 lines. + +### Changed +- The global report has no silent cap: full CSV files and a light HTML page that stays fast with thousands of objects. +- A Recover warns about objects changed since their batch, and *Deny* entries of a shared mailbox are reported. +- A phase can be run again from the same transfer package. + +### Fixed +- A run that is interrupted (Ctrl+C, closed window) never ends as a success; a partly converted batch can be continued or rolled back. + ## 3.1.4 — 2026-11-13 ### Added diff --git a/README.md b/README.md index d0f4697..1968125 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@

> [!TIP] -> **Download the latest release.** Open the [latest release](https://github.com/Nico77600/PraRemoteMailbox/releases/latest) and download **`PraRemoteMailbox-3.1.4.zip`** under *Assets* (its SHA-256 is in the release notes). That ZIP is the signed tool, with the HTML guides. Do not use the **Source code** archives or the green **Code** button: they are a copy of the repository, not the release package. +> **Download the latest release.** Open the [latest release](https://github.com/Nico77600/PraRemoteMailbox/releases/latest) and download **`PraRemoteMailbox-3.2.0.zip`** under *Assets* (its SHA-256 is in the release notes). That ZIP is the signed tool, with the HTML guides. Do not use the **Source code** archives or the green **Code** button: they are a copy of the repository, not the release package. > [!IMPORTANT] > Files downloaded from the Internet may be blocked by Windows and fail to run. Before using this project, unblock every file in the downloaded folder: @@ -48,10 +48,10 @@ In a hybrid organisation, a mailbox hosted on-premises is only a *mail user* for Done by hand, this means rewriting about ten Exchange attributes per object in Active Directory, for hundreds of objects, under stress — and keeping every original value to come back later: a wrong or lost value cannot be repaired without a backup. This tool does the conversion in a planned, verified and **reversible** way. -**Author:** Nicolas Fabert · **Version:** 3.1.4, 2026-11-13 ([changelog](CHANGELOG.md)). +**Author:** Nicolas Fabert · **Version:** 3.2.0, 2026-11-22 ([changelog](CHANGELOG.md)). > [!CAUTION] -> Convert creates **new, empty** mailboxes in Exchange Online: the content of the on-premises mailboxes is not moved. A Recover deprovisions the cloud mailboxes: export first what was received in the cloud during the disaster, or protect it with a retention policy (reference guide, chapter 6). +> Convert creates **new, empty** mailboxes in Exchange Online: the content of the on-premises mailboxes is not moved. A Recover deprovisions the cloud mailboxes: export first what was received in the cloud during the disaster, or protect it with a retention policy (reference guide, chapter 6). Before it removes anything, a Recover checks that the retention policy holds the mailboxes and stops when it does not (`-AcceptRetentionRisk` accepts the risk for one run). ## Get started @@ -68,7 +68,7 @@ One path for everyone. Set the tool up once (**1 to 4**), then take branch **A** # 1 · Get your rights. Give the table "Requirements" below to your administrator (minimum rights, derived from the code). # 2 · On the server, in PowerShell 7.5+ as administrator: put the tool in its folder and unblock it. -# Download PraRemoteMailbox-3.1.4.zip from the latest release (under Assets, not Source code) and extract it to D:\PRA\PraRemoteMailbox +# Download PraRemoteMailbox-3.2.0.zip from the latest release (under Assets, not Source code) and extract it to D:\PRA\PraRemoteMailbox Get-ChildItem D:\PRA\PraRemoteMailbox -Recurse -File -Force | Unblock-File Install-Module ExchangeOnlineManagement -MinimumVersion 3.10.1 -Scope AllUsers -Force Install-Module Microsoft.Graph.Authentication -MinimumVersion 2.41.1 -Scope AllUsers -Force # one command per module: PowerShellGet refuses -MinimumVersion with several names @@ -204,7 +204,7 @@ Exchange on-premises is down, so the tool reads the permissions where Exchange k Open the console with `pwsh -STA -File .\package\Invoke-PraRemoteMailbox.ps1 -Gui` (native Fluent theme, PowerShell 7.5+, English). It starts no operation by itself; every operation runs the existing engine in a separate **PowerShell 7.5+** process (the same `pwsh.exe`). -The console is a guided path of five pages: **Setup** (the environment, what this server can run, the prerequisite lights from real detection, one line of run settings), **Task** (move mailboxes, roll back, complete a rollback, check a mailbox, on what: one identity to test first, the configured scope, an OU or a CSV, or a batch or package to continue), **Verify** (the Preview in plain words, then the confirmation word in any letter case), **Run** (the steps announced by the engine, with their waits and warnings in plain words; click a step or an object) and **Next steps**. Run settings changed in the window apply to that run only, through a guarded effective copy of the configuration: the file is never rewritten. See the [reference guide, chapter 8](package/docs/PraRemoteMailbox-Guide.md#8-everyday-use). +The console is a guided path of five pages: **Setup** (the environment, what this server can run, the prerequisite lights from real detection, one line of run settings), **Task** (move mailboxes, roll back, complete a rollback, check a mailbox, on what: one identity to test first, the configured scope, an OU or a CSV, or a batch or package to continue), **Verify** (the Preview in plain words, then the confirmation word in any letter case), **Run** (the steps announced by the engine, with their waits and warnings in plain words; click a step or an object) and **Next steps**. The batch lists show what is **To do** and what is **Finished**. Run settings changed in the window apply to that run only, through a guarded effective copy of the configuration: the file is never rewritten. See the [reference guide, chapter 8](package/docs/PraRemoteMailbox-Guide.md#8-everyday-use). @@ -221,7 +221,7 @@ Every run writes a log, a PowerShell transcript, a CSV and an HTML report. Exit The HTML report of a run with a warning on a shared mailbox, and the list of warnings below the table
Warnings · something was left aside on purpose: shown in the console, the log, the CSV and the report - The global report of a Convert across two servers: the times of the AD server and of the cloud server, then every person from end to end
Global report · on two servers, the last server writes one report that follows each object from the first server to the last + The global report of a Convert across two servers: the times of the AD server and of the cloud server, then every person from end to end
Global report · on two servers, the last server writes one report that follows each object from the first server to the last, with every object in full CSV files and a light HTML page The global report of a rollback across three phases: Recover on the AD server, Recover on the cloud server, Finalize
Rollback · Recover on the AD server, Recover on the cloud server, then Finalize, in one report @@ -285,7 +285,7 @@ Both guides also exist as a single HTML file with a light and a dark theme (`pac pwsh -NoProfile -File .\tests\Invoke-TestGate.ps1 # no directory, no tenant needed ``` -The gate runs the real entry script against a synthetic Active Directory, Entra Connect and Exchange Online: no write before the complete backup, stop at the first error, no write in Preview, no Apply without confirmation, memory bounds, proofs and Finalize packages. It also exercises WPF selection, Preview/Apply guards and OU/CSV targeting, and checks the documentation (pictures, names, the Graph scope documented against the one of the code). Earlier versions were validated on a real Active Directory, Entra Connect and Microsoft 365 tenant (reference guide, annex B); **3.0.0 has offline validation only, not a new live-tenant campaign** (the lab list for the PowerShell 7 engine is in the guide, annex B). Files written by the real 2.2.0 under Windows PowerShell 5.1 are replayed by the gate (`tests\PraLegacyFixtures.Tests.ps1`, fixtures frozen in `tests\fixtures\ps51-2.2.0`). `tools\Build-Documentation.ps1` and `tools\New-DocumentationImages.ps1`, which rebuild the HTML guides and the pictures on a workstation, need PowerShell 7.5+ (and Microsoft Edge for the pictures). +The gate runs the real entry script against a synthetic Active Directory, Entra Connect and Exchange Online: no write before the complete backup, stop at the first error, no write in Preview, no Apply without confirmation, memory bounds, proofs and Finalize packages. It also exercises WPF selection, Preview/Apply guards and OU/CSV targeting, and checks the documentation (pictures, names, the Graph scope documented against the one of the code). Earlier versions were validated on a real Active Directory, Entra Connect and Microsoft 365 tenant (reference guide, annex B); **3.2.0 was validated on a real lab** with two servers (Convert, Recover, the retention check before Recover, interrupted runs). Files written by the real 2.2.0 under Windows PowerShell 5.1 are replayed by the gate (`tests\PraLegacyFixtures.Tests.ps1`, fixtures frozen in `tests\fixtures\ps51-2.2.0`). `tools\Build-Documentation.ps1` and `tools\New-DocumentationImages.ps1`, which rebuild the HTML guides and the pictures on a workstation, need PowerShell 7.5+ (and Microsoft Edge for the pictures). ## License diff --git a/package/Invoke-PraRemoteMailbox.ps1 b/package/Invoke-PraRemoteMailbox.ps1 index 58aa55d..e455cf1 100644 --- a/package/Invoke-PraRemoteMailbox.ps1 +++ b/package/Invoke-PraRemoteMailbox.ps1 @@ -93,6 +93,12 @@ list), then read back on each of them. A domain controller that does not confirm is a warning that names it; the synchronisation still runs and the Next steps say how to run it again later. Needs the right to replicate a single object (normally Domain Admins). A Preview never replicates. +.PARAMETER AcceptRetentionRisk + Recover, AD part only. Before it removes the cloud mailboxes, a Recover reads each mailbox that carries the retention tag and checks that the retention policy holds it + (Retention.CheckBeforeRecover in the configuration file). The Apply stops, before any change, when a mailbox is not covered or cannot be checked. This switch goes on for + this one run anyway: the run lists what is not covered in a warning, in the log, in the summary and in the report. It is not remembered. The check itself is turned off in + the configuration file (Retention.CheckBeforeRecover = $false), not here. + .PARAMETER Force Apply without the confirmation prompt (scheduled or unattended runs). Never skips a safety check. The single confirmation of an Apply is also skipped when -Confirm is given explicitly, with either value: @@ -149,7 +155,7 @@ .NOTES Author : Nicolas Fabert - Version : 3.1.4 + Version : 3.2.0 Requires : PowerShell 7.5 or later (pwsh.exe; Windows PowerShell 5.1 is refused), RSAT ActiveDirectory, ExchangeOnlineManagement 3.10.1+, Microsoft.Graph.Authentication and Microsoft.Graph.Users 2.41.1+ in one same version (cloud part), ADSync (sync; through the Windows PowerShell compatibility layer when local). @@ -183,6 +189,7 @@ param( [string]$ConfigPath, [Parameter(ParameterSetName = 'Run')][string]$BaseConfigPath, [Parameter(ParameterSetName = 'Run')][switch]$ForceAdReplication, + [Parameter(ParameterSetName = 'Run')][switch]$AcceptRetentionRisk, [Parameter(ParameterSetName = 'Run')][switch]$Force, [Parameter(ParameterSetName = 'Run')][switch]$Once, [Parameter(ParameterSetName = 'Run')][switch]$PassThru, @@ -283,7 +290,7 @@ $context = @{ Once = [bool]$Once; IntervalMinutes = 0; TimeoutMinutes = 0 VerboseEnabled = ((Test-PraOrdinalIgnoreCaseEqual $VerbosePreference 'Continue') -or (Test-PraOrdinalIgnoreCaseEqual $DebugPreference 'Continue')) SourceBackupHash = ''; Source = $null; Proof = $null; LastVerifiedReceipt = $null; OperationFailed = $false; JournalPath = '' - BatchId = ''; NextSteps = @() + BatchId = ''; NextSteps = @(); RunReachedEnd = $false; ChangesStarted = $false } $context.Approval = New-PraApprovalCallback $caller $context # Lets the modules write a command line of this run's own style (-ConfigPath kept) in a message; defined here because Get-PraCommandLine is a function of this script. @@ -312,13 +319,13 @@ function ConvertTo-PraLiteral { function Get-PraCommandLine { <# Command line suggested in "Next step", with the options of this run that still apply. Every free-text value is quoted as data. #> param([string]$ActionName, [string]$ModeName = 'Apply', [string]$PhaseName = '', [string]$BatchId = '', [switch]$KeepFilters, [switch]$OtherServer, - [ValidateSet('', 'Identity', 'SearchBase', 'CsvPath', 'Group', 'None')][string]$Only = '', [string]$GroupName = '') + [ValidateSet('', 'Identity', 'SearchBase', 'CsvPath', 'Group', 'None')][string]$Only = '', [string]$GroupName = '', [string]$CsvOverride = '') $parts = @('.\Invoke-PraRemoteMailbox.ps1', "-Action $ActionName") # With -Only, the one object selector kept (-Identity, -SearchBase, -CsvPath or -Group; None keeps no selector): the others are left out. $keepSelector = { param([string]$Name) (-not $Only) -or (Test-PraOrdinalIgnoreCaseEqual $Only $Name) } if ($PhaseName) { $parts += "-Phase $PhaseName" } if ((Test-PraOrdinalIgnoreCaseEqual $ModeName 'Apply')) { $parts += '-Mode Apply' } - if ($BatchId) { $parts += $(if ($BatchId -match '^[0-9a-fA-F]+$') { "-Batch $BatchId" } else { '-Batch ' + (ConvertTo-PraLiteral $BatchId) }) } + if ($BatchId) { $parts += $(if ($BatchId -match '^[0-9a-fA-F]+\z') { "-Batch $BatchId" } else { '-Batch ' + (ConvertTo-PraLiteral $BatchId) }) } if ($KeepFilters) { if ($Identity -and (& $keepSelector 'Identity')) { $parts += '-Identity ' + (ConvertTo-PraLiteral $Identity) } if ((-not (Test-PraOrdinalIgnoreCaseEqual $Scope 'All'))) { $parts += "-Scope $Scope" } @@ -327,10 +334,12 @@ function Get-PraCommandLine { $groupValue = if ($GroupName) { $GroupName } else { $Group } if ($groupValue -and (& $keepSelector 'Group')) { $parts += '-Group ' + (ConvertTo-PraLiteral $groupValue) } # On another server the CSV file is a file of that server: only its name is written, the operator copies the file there. - if ($CsvPath -and (& $keepSelector 'CsvPath')) { $parts += '-CsvPath ' + (ConvertTo-PraLiteral $(if ($OtherServer) { [IO.Path]::GetFileName($CsvPath) } else { $CsvPath })) } + if ($CsvPath -and -not $CsvOverride -and (& $keepSelector 'CsvPath')) { $parts += '-CsvPath ' + (ConvertTo-PraLiteral $(if ($OtherServer) { [IO.Path]::GetFileName($CsvPath) } else { $CsvPath })) } if ((Test-PraOrdinalIgnoreCaseEqual $ActionName 'Check') -and -not (Test-PraOrdinalIgnoreCaseEqual $Expect 'Provisioned')) { $parts += "-Expect $Expect" } if ($Once) { $parts += '-Once' } } + # A file made by this run for the objects that are still to convert replaces the CSV of the run. + if ($CsvOverride) { $parts += '-CsvPath ' + (ConvertTo-PraLiteral $CsvOverride) } # On another server the configuration file is that server's own: -ConfigPath is not repeated. # Run from the window, -ConfigPath is the generated configuration of that run: the suggested command names the configuration file itself. if ($script:ConfigPathBound -and -not $OtherServer) { $parts += '-ConfigPath ' + (ConvertTo-PraLiteral $(if ($BaseConfigPath) { $BaseConfigPath } else { $ConfigPath })) } @@ -392,6 +401,8 @@ function Get-PraFallbackNext { } if ($applied -and $newBatch) { $batchId = [string]$context.BatchId + $partial = Get-PraValue $context 'PartialBatch' $null + if ($null -ne $partial) { return @(Get-PraPartialStopStep $partial) } if ($null -ne $context.Proof -and $batchId) { $kept = 'What this run already did is kept (Active Directory is changed and verified).' if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Convert') -and (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'AD')) { @@ -399,6 +410,22 @@ function Get-PraFallbackNext { } return @(('{0} Fix the problem named above, then run the Exchange Online part:' -f $kept), (Get-PraCommandLine -ActionName $Action -PhaseName 'Cloud' -BatchId $batchId)) } + $mayBe = @(Get-PraList $context 'MayBeChanged') + if (($written -gt 0 -or $mayBe.Count) -and $batchId -and (Test-PraOrdinalIgnoreCaseEqual $Action 'Convert')) { + $changed = [Math]::Max($written, $mayBe.Count) + $verified = @($context.Rows | Where-Object { (Get-PraValue $_ 'ADVerified' $false) -eq $true }).Count + $stateFolder = [string](Get-PraValue $context 'PhaseWriteFolder' '') + $stateWritten = [bool]($stateFolder -and (Test-Path -LiteralPath $stateFolder -PathType Container) -and @(Get-ChildItem -LiteralPath $stateFolder -File -Filter ('State-' + $batchId + '*.json') -ErrorAction SilentlyContinue).Count) + $rollback = @('To put them back as they were, roll the batch back (run the Preview first, then the same command with -Mode Apply):', + (Get-PraCommandLine -ActionName 'Recover' -ModeName 'Preview' -BatchId $batchId), + 'To see first what the batch holds in Exchange Online, run the Check:', (Get-PraCommandLine -ActionName 'Check' -ModeName 'Preview' -BatchId $batchId)) + if ($verified -ge $changed -and $verified -gt 0 -and $stateWritten) { + return @(('Active Directory was changed for {0} object(s) before the stop (see the journal and the backup named above) and all {1} were verified: the stop came after the verification. To go on with this batch (the verified objects are not changed again: it runs the Entra Connect synchronisation and writes the transfer package), run:' -f $changed, $verified), + (Get-PraCommandLine -ActionName 'Convert' -PhaseName 'AD' -BatchId $batchId)) + $rollback + } + $state = if ($verified -gt 0) { ('{0} of them {1} verified, the others are not' -f $verified, $(if ($verified -eq 1) { 'is' } else { 'are' })) } else { 'none of them is verified' } + return @(('Active Directory {0} for {1} object(s) before the stop (see the journal and the backup named above) and {2}. Do not run the Apply again before reading what is left. {3}' -f $(if ($written -gt 0) { 'was changed' } else { 'may have been changed' }), $changed, $state, $rollback[0])) + @($rollback | Select-Object -Skip 1) + } if ($written -gt 0) { return @(('Active Directory was changed for {0} object(s) before the stop (see the journal and the backup named above). Do not run the Apply again before reading what is left: run the Preview of the same command:' -f $written), (Get-PraCommandLine -ActionName $Action -PhaseName $phaseName -ModeName 'Preview' -BatchId $typedBatch -KeepFilters)) @@ -409,6 +436,49 @@ function Get-PraFallbackNext { return @('Fix the problem named above, then run the same command again:', $same) } +function Get-PraJsonHeader { + <# + .SYNOPSIS + Some scalar fields of a batch JSON file (Operation, BatchId, SourceBackupHash), read without parsing the whole file. + .DESCRIPTION + A backup of thousands of objects is tens of megabytes; the scalar fields of its envelope come before its records. The head of the file is read and each field + is taken from it when only plain scalar properties (text without escapes, numbers, true, false, null) come before it, so that a nested property of the same name + is never taken. Any other shape, a field that is not there, or a file that cannot be read this way is parsed in full. + .OUTPUTS + An object with the requested fields (the whole parsed file when it had to be parsed). + #> + param([Parameter(Mandatory)][string]$Path, [Parameter(Mandatory)][string[]]$Name) + $head = '' + try { + $stream = [IO.File]::Open($Path, [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite) + try { + $buffer = New-Object 'byte[]' 8192 + $count = $stream.Read($buffer, 0, $buffer.Length) + $head = [Text.Encoding]::UTF8.GetString($buffer, 0, $count).TrimStart([char]0xFEFF) + } finally { $stream.Dispose() } + } catch { $head = '' } + $values = New-Object 'Collections.Generic.Dictionary[string,string]' ([StringComparer]::Ordinal) + $open = [regex]::Match($head, '\A\s*\{') + if ($open.Success) { + $pair = [regex]::new('\G\s*"(?[^"\\]*)"\s*:\s*(?:"(?[^"\\]*)"|(?-?[0-9]+(?:\.[0-9]+)?(?:[eE][-+]?[0-9]+)?|true|false|null))\s*(?,|\})') + $position = $open.Length + while ($true) { + $m = $pair.Match($head, $position) + if (-not $m.Success) { break } + $position = $m.Index + $m.Length + $key = $m.Groups['n'].Value + if (-not $values.ContainsKey($key)) { $values[$key] = $(if ($m.Groups['s'].Success) { $m.Groups['s'].Value } else { $m.Groups['x'].Value }) } + if (Test-PraOrdinalEqual $m.Groups['end'].Value '}') { break } + } + } + $header = [ordered]@{} + foreach ($field in $Name) { + if (-not $values.ContainsKey($field)) { return ([IO.File]::ReadAllText($Path) | ConvertFrom-PraJson) } + $header[$field] = $values[$field] + } + return [pscustomobject]$header +} + function Get-PraBatchFile { <# .SYNOPSIS @@ -429,7 +499,7 @@ function Get-PraBatchFile { elseif (Test-Path -LiteralPath $candidate -PathType Leaf) { return $candidate } else { throw "Batch file or folder not found: $candidate" } } else { - if ($Value -notmatch '^[0-9a-fA-F]{8,32}$') { throw "Invalid batch ID '$Value': use the 8 characters (or more) shown at the end of the previous run, or the path of the batch JSON file." } + if ($Value -notmatch '^[0-9a-fA-F]{8,32}\z') { throw "Invalid batch ID '$Value': use the 8 characters (or more) shown at the end of the previous run, or the path of the batch JSON file." } if (-not (Test-Path -LiteralPath $context.BackupFolder -PathType Container)) { $isCheck = (Test-PraOrdinalIgnoreCaseEqual $Action 'Check') $packageSuffix = if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Finalize')) { '-for-AD.zip' } else { '-for-Cloud.zip' } @@ -449,8 +519,8 @@ function Get-PraBatchFile { } $found = New-Object 'Collections.Generic.List[string]' foreach ($folder in $folders) { - foreach ($file in @(Get-ChildItem -LiteralPath $folder.FullName -File -Filter '*.json' -ErrorAction Stop | Where-Object { -not $_.Name.StartsWith('State-', [StringComparison]::OrdinalIgnoreCase) })) { - try { $operation = [string](([IO.File]::ReadAllText($file.FullName) | ConvertFrom-PraJson).Operation) } catch { continue } + foreach ($file in @(Get-ChildItem -LiteralPath $folder.FullName -File -Filter '*.json' -ErrorAction Stop | Where-Object { -not (Test-PraBatchSideFile $_.Name) })) { + try { $operation = [string](Get-PraJsonHeader $file.FullName @('Operation')).Operation } catch { continue } # In a Finalize package only the manifest counts (the other JSON files are copies of the source batches). if ((Test-PraOrdinalIn $operation $Operations) -and ($folder.Name -match '^Batch-' -or (Test-PraOrdinalEqual $operation 'RecoverFinalize'))) { $found.Add($file.FullName) } } @@ -496,16 +566,15 @@ function Initialize-PraCloudAuthority { <# .SYNOPSIS Callbacks given to the cloud module. Before each Exchange Online write, AssertCloudAuthorization - re-reads the AD proof of the object; JournalMutation records the write in the batch journal. + checks the AD proof of the object (read in full once, then by its stamps) and the backup; JournalMutation records the write in the batch journal. #> # GetNewClosure captures local variables, not the $context of the script: copy it first. $capturedContext = $context $context.AssertCloudAuthorization = { param($Row) if (-not $capturedContext.AllowMutation -or $capturedContext.OperationFailed -or $capturedContext.Issues.Count -gt 0 -or $null -eq $capturedContext.Proof) { throw 'Cloud write refused: no authorisation or the run already has an error.' } - $proof = Import-PraProof $capturedContext $capturedContext.Proof.Path $capturedContext.Source $capturedContext.Action - if (@($proof.Data.Records | Where-Object { Test-PraOrdinalIgnoreCaseEqual $_.ObjectGuid $Row.ObjectGuid }).Count -ne 1) { throw 'Cloud write refused: the object is not in a verified AD phase.' } - Assert-PraReceipt $capturedContext $capturedContext.Source $Row.ObjectGuid + Assert-PraCloudProofObject -Context $capturedContext -ProofPath $capturedContext.Proof.Path -Source $capturedContext.Source -Operation $capturedContext.Action -ObjectGuid ([string]$Row.ObjectGuid) + Assert-PraReceipt $capturedContext $capturedContext.Source ([string]$Row.ObjectGuid) }.GetNewClosure() $context.JournalMutation = { param($Target, $Operation, $Status, $Detail) Write-PraJournal $capturedContext $Target $Operation $Status ([string]$Detail) }.GetNewClosure() } @@ -591,27 +660,33 @@ function Get-PraFinalizeInput { } $context.Source = Import-PraBackup $context (Join-Path (Split-Path $path -Parent) $manifest.SourceBackupFile) $context.PhaseFolders = @(Split-Path $path -Parent) + if ($context.AllowMutation) { $context.PhaseWriteFolder = Split-Path $path -Parent } $context.Proof = Import-PraProof $context (Join-Path (Split-Path $path -Parent) $manifest.StateFile) $context.Source 'Recover' if (-not (Test-PraOrdinalIgnoreCaseEqual $context.Source.Hash $manifest.SourceBackupHash) -or -not (Test-PraOrdinalIgnoreCaseEqual $context.Proof.Hash $manifest.StateHash)) { throw 'Finalize package: manifest and proofs do not match.' } $records = @(Select-PraSourceRecord $context.Source); $seen = @{} $items = @($manifest.Items) if (-not $items.Count) { throw 'Finalize package is empty.' } + $proofIndex = Get-PraRecordIndex $context.Proof.Data.Records + $snapshotIndex = Get-PraRecordIndex $context.Proof.Receipt.Data.Records + $sourceIndex = Get-PraRecordIndex $context.Source.Data.Records foreach ($item in $items) { if ($item.CloudConfirmed -isnot [bool] -or -not $item.CloudConfirmed -or $item.DeprovisionConfirmed -isnot [bool] -or -not $item.DeprovisionConfirmed -or $item.RestoreShared -isnot [bool] -or $item.RestoreTag -isnot [bool] -or - -not (Test-PraOrdinalIn $item.ObjectGuid @($context.Proof.Data.Records.ObjectGuid) -IgnoreCase) -or $seen.ContainsKey($item.ObjectGuid)) { throw 'Finalize package: invalid object confirmation.' } - $proofEntry = @($context.Proof.Data.Records | Where-Object { Test-PraOrdinalIgnoreCaseEqual $_.ObjectGuid $item.ObjectGuid })[0] - $snapshotEntry = @($context.Proof.Receipt.Data.Records | Where-Object { Test-PraOrdinalIgnoreCaseEqual $_.ObjectGuid $item.ObjectGuid })[0] - $sourceEntry = @($context.Source.Data.Records | Where-Object { Test-PraOrdinalIgnoreCaseEqual $_.ObjectGuid $item.ObjectGuid })[0] + $null -eq (Find-PraRecord $proofIndex ([string]$item.ObjectGuid)) -or $seen.ContainsKey($item.ObjectGuid)) { throw 'Finalize package: invalid object confirmation.' } + $proofEntry = Find-PraRecord $proofIndex ([string]$item.ObjectGuid) + $snapshotEntry = Find-PraRecord $snapshotIndex ([string]$item.ObjectGuid) + $sourceEntry = Find-PraRecord $sourceIndex ([string]$item.ObjectGuid) if ($snapshotEntry.PreserveCloudMailbox -or ($item.RestoreShared -and (-not (Test-PraOrdinalEqual $proofEntry.Operation 'Deprovision') -or -not $sourceEntry.IsShared)) -or ($item.RestoreTag -and -not [bool](Get-PraValue (Get-PraValue $sourceEntry 'Retention' $null) 'Enabled' $false)) -or (-not $item.RestoreShared -and -not $item.RestoreTag)) { throw 'Finalize package does not match the AD operations it proves.' } $seen[$item.ObjectGuid] = $true } - if ($Identity -and @($records | Where-Object { Test-PraOrdinalIn $_.ObjectGuid @($items.ObjectGuid) -IgnoreCase }).Count -ne 1) { throw "Identity '$Identity' is not authorised by this Finalize package." } + $itemByGuid = New-Object 'Collections.Generic.Dictionary[string,object]' ([StringComparer]::OrdinalIgnoreCase) + foreach ($item in $items) { $itemByGuid[[string]$item.ObjectGuid] = $item } + $authorised = New-Object 'Collections.Generic.List[object]' + foreach ($record in $records) { if ($itemByGuid.ContainsKey([string]$record.ObjectGuid)) { $authorised.Add($record) } } + if ($Identity -and $authorised.Count -ne 1) { throw "Identity '$Identity' is not authorised by this Finalize package." } $context.BatchId = Get-PraShortId ((Split-Path (Split-Path $path -Parent) -Leaf) -replace '^Finalize-', '') - return @($records | Where-Object { Test-PraOrdinalIn $_.ObjectGuid @($items.ObjectGuid) -IgnoreCase } | ForEach-Object { - $recordGuid = $_.ObjectGuid - [pscustomobject]@{ Record = $_; Item = ($items | Where-Object { Test-PraOrdinalIgnoreCaseEqual $_.ObjectGuid $recordGuid }) } }) + return @($authorised | ForEach-Object { [pscustomobject]@{ Record = $_; Item = $itemByGuid[[string]$_.ObjectGuid] } }) } function Format-PraByteSize { @@ -640,8 +715,14 @@ function Publish-PraTransferPackage { $context.HandOff = $Kind $phaseFolder = [string](Get-PraValue $context 'PhaseWriteFolder' '') if ($phaseFolder -and -not [bool](Get-PraValue $context 'PhaseDataSaved' $false)) { - try { $null = Save-PraPhaseData -Context $context -Folder $phaseFolder -HandOff $Kind; $context.PhaseDataSaved = $true } - catch { Write-PraLog -Context $context -Message ('The data for the global report could not be saved ({0}): the package is complete, the other server will report this side as not available.' -f $_.Exception.Message) -Level Warning } + $saved = '' + try { $saved = Save-PraPhaseData -Context $context -Folder $phaseFolder -HandOff $Kind; $context.PhaseDataSaved = $true } + catch { Write-PraLog -Context $context -Message ('The data for the global report could not be saved ({0}): the package is complete and the other server can go on, but its global report will say that this side is not available. To find the cause, check the rights on the batch folder with: Get-Acl -LiteralPath ''{1}'' | Format-List Owner, AccessToString and the free space with: Get-PSDrive -PSProvider FileSystem' -f $_.Exception.Message, $phaseFolder.Replace("'", "''")) -Level Warning } + # The cloud phase of a Recover also leaves its data in the batch of the AD rollback, so that the console can tell that its cloud part is done. + if ($saved -and (Test-PraOrdinalIgnoreCaseEqual $Kind 'Finalize') -and $null -ne (Get-PraValue $context 'Proof' $null)) { + try { $null = Copy-PraPhaseFile -Path $saved -Destination (Split-Path $context.Proof.Path -Parent) } + catch { Write-PraLog -Context $context -Message ('The data of this phase could not be copied to the batch of the AD rollback ({0}).' -f $_.Exception.Message) -Level Detail } + } } try { $name = Get-PraTransferPackageName -Kind $Kind -Environment $context.Config.Environment -BatchId $BatchId @@ -720,6 +801,313 @@ function Test-PraCloudModuleAvailable { $context.ApplyBlockers = @(Get-PraList $context 'ApplyBlockers') + 'install or update the cloud modules with the commands in the warning above' } +function Get-PraRetentionProofFolder { + <# The folders where a retention proof is looked for, as for a transfer package: Inbox, Outbox (under Storage.BackupFolder) and the folder of the Convert batch. #> + $folders = @((Join-Path $context.BackupFolder 'Inbox'), (Join-Path $context.BackupFolder 'Outbox')) + if ($null -ne $context.Source -and [string](Get-PraValue $context.Source 'Path' '')) { $folders += (Split-Path ([string]$context.Source.Path) -Parent) } + return [string[]]$folders +} + +function Get-PraRunHostState { + <# What this process says about being interactive: the arguments of its command line, whether it has a user, whether its input is redirected. #> + $redirected = $true + try { $redirected = [Console]::IsInputRedirected } catch { $redirected = $true } + return [pscustomobject]@{ CommandLine = [string[]]@([Environment]::GetCommandLineArgs()); UserInteractive = [bool][Environment]::UserInteractive; InputRedirected = [bool]$redirected } +} + +function Test-PraRunCanSignIn { + <# True when a person can answer an interactive sign-in in this run: no -Force, no -NonInteractive on the command line of the process (with one or two dashes, a slash, an en or em dash, or an abbreviation of at least -noni), a host with a user, and an input that is not redirected (the window starts the engine with its input closed). #> + if ($Force) { return $false } + $state = Get-PraRunHostState + foreach ($argument in $state.CommandLine) { if ($argument -match '(?i)\A(--?|/|[–—])noni') { return $false } } + return ([bool]$state.UserInteractive -and -not [bool]$state.InputRedirected) +} +function Save-PraRetentionProof { + <# + .SYNOPSIS + Check -Expect Retained on a batch: writes the retention proof (the verdict of each object) in the Outbox folder, with its .sha256 file, for the AD server that cannot ask Exchange Online. + #> + param([Parameter(Mandatory)][AllowEmptyCollection()][object[]]$Rows) + if ($null -eq $context.Source -or -not $Batch -or -not $Rows.Count) { return } + $objects = New-Object 'Collections.Generic.List[object]' + $checked = 0 + foreach ($row in $Rows) { + $verdict = [string](Get-PraValue $row 'RetentionVerdict' 'NotChecked') + if (-not (Test-PraOrdinalEqual $verdict 'NotChecked')) { $checked++ } + $objects.Add([pscustomobject]@{ ObjectGuid = [string]$row.ObjectGuid; Upn = [string]$row.UserPrincipalName; Verdict = $verdict }) + } + if (-not $checked) { return } + $context.CurrentOperation = 'Write-RetentionProof'; $context.CurrentIdentity = '' + # The proof is for the other server: it goes to the Outbox of the backup folder of this server, also when the batch was read from a package in a temporary preview folder. + $outbox = Join-Path ([string]$context.Config.Storage.BackupFolder) 'Outbox' + try { + $guids = @([string](Get-PraValue $context 'RetentionPolicyGuid' '')) + $written = Write-PraRetentionProof -Folder $outbox -BatchId ([string]$context.Source.Data.BatchId) -SourceBackupHash ([string]$context.Source.Hash) -Environment ([string]$context.Config.Environment) -PolicyGuid $guids -Object $objects.ToArray() + $withoutMailbox = @($objects | Where-Object { Test-PraOrdinalEqual $_.Verdict 'NoMailbox' }).Count + Write-PraItem -Context $context -Status Ok -Icon Batch -Text ('Retention proof written: {0} of {1} object(s) covered{2} ({3})' -f $written.CoveredCount, $written.ObjectCount, $(if ($withoutMailbox) { ', {0} without a mailbox in Exchange Online (nothing to retain)' -f $withoutMailbox } else { '' }), $written.Path) -Detail $written.Path + $next = Get-PraCommandLine -ActionName 'Recover' -PhaseName 'AD' -ModeName 'Preview' -BatchId (Get-PraShortId ([string]$context.Source.Data.BatchId)) -OtherServer + $context.NextSteps = @(Get-PraList $context 'NextSteps') + @(('For the Recover on the AD server, copy these two files to its Backups\Inbox folder: {0} and {1}. The AD server accepts a proof for as many hours as its own Retention.ProofMaxAgeHours says (24 by default), so copy them soon. Then run there:' -f $written.Path, $written.Sidecar), $next) + } + catch { + Write-PraItem -Context $context -Status Warn -Icon Batch -Text ('The retention proof could not be written ({0}): the check itself is not affected.' -f $_.Exception.Message) + $typedBatch = if ($script:PackageArgument) { $script:PackageArgument } else { $Batch } + $context.NextSteps = @(Get-PraList $context 'NextSteps') + @(('To write the retention proof, make sure this account can write in the folder {0} (rights, free space), then run the same Check again:' -f $outbox), (Get-PraCommandLine -ActionName 'Check' -ModeName 'Preview' -BatchId $typedBatch -KeepFilters)) + } +} + +function Write-PraRetentionNoMailbox { + <# + .SYNOPSIS + Objects that Exchange Online has no mailbox for (active or inactive): a warning for each (the first ten, the others are in the log) and one for the count, unless the cloud part of the Convert is recorded as not completed for the object (then the log only). Nothing is retained for them; the Recover is not stopped. + .PARAMETER Entry + ObjectGuid and Upn of each object. + #> + param([AllowEmptyCollection()][object[]]$Entry = @()) + if (-not @($Entry).Count) { return } + $done = $null + try { $done = Get-PraConvertCloudDone -Folder (Split-Path ([string]$context.Source.Path) -Parent) -BatchId ([string]$context.Source.Data.BatchId) -Environment ([string]$context.Config.Environment) } catch { $done = $null } + $visible = New-Object 'Collections.Generic.List[object]' + foreach ($item in $Entry) { + $completed = ($null -ne $done -and $done.Known -and $done.Done.Contains([string]$item.ObjectGuid)) + if ($null -eq $done -or -not $done.Known -or $completed) { $visible.Add($item) } + else { Write-PraLog -Context $context -Message ('{0}: no mailbox in Exchange Online, and the cloud part of the Convert is not recorded as complete for it: nothing to retain' -f $item.Upn) -Level Detail } + } + $limit = 10; $shown = 0 + foreach ($item in $visible) { + if ($shown -ge $limit) { Write-PraLog -Context $context -Message ('{0}: no mailbox in Exchange Online (active or inactive)' -f $item.Upn) -Level Detail; continue } + $context.CurrentIdentity = [string]$item.ObjectGuid + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('{0}: Exchange Online has no mailbox for this object, active or inactive, and its mailbox is expected to be there after the Convert. Nothing is retained for it and the Recover goes on. Check that this is expected (Get-EXOMailbox -Identity ''{1}''; Get-EXOMailbox -InactiveMailboxOnly -Filter "UserPrincipalName -eq ''{1}''").' -f $item.Upn, ([string]$item.Upn).Replace("'", "''")) + $shown++ + } + $context.CurrentIdentity = '' + if ($visible.Count) { Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('{0} object(s) have no mailbox in Exchange Online: nothing is retained for them{1}.' -f $visible.Count, $(if ($visible.Count -gt $shown) { ' (the others are named in the log)' } else { '' })) } +} + +function Invoke-PraRetentionGate { + <# + .SYNOPSIS + Recover, AD part: before the cloud mailboxes are removed, checks that the retention policy holds each mailbox that carries the retention tag (Retention.CheckBeforeRecover). + .DESCRIPTION + Read only. Exchange Online is asked wherever this run can ask it without a person (phase Both, a certificate sign-in) or with the person who runs it (phase AD at an interactive console, without -Force); + the mailboxes that carry the tag are read in bulk (Test-PraRetentionCoverage). When Exchange Online answers, its answer decides and no retention proof is read. When it cannot be reached or asked on the AD part + (no sign-in, no answer, throttling, the cloud modules missing, no person to sign in), the retention proof that a Check wrote on the cloud server stands in for it when it is intact, recent, of this batch and + covers every object. Apply: a mailbox that the policy does not hold, or that cannot be checked, STOPS the run here, before the confirmation and before any change, unless -AcceptRetentionRisk was given (then a warning, + the summary and the report say so). Preview: the same answer as warnings; the Apply is refused until it is fixed. Retention.CheckBeforeRecover = $false: no check, said once in a warning. + #> + param([Parameter(Mandatory)][AllowEmptyCollection()][object[]]$Plans) + if (-not [bool]$context.Config.Retention.CheckBeforeRecover) { + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text 'The retention check before a Recover is turned off (Retention.CheckBeforeRecover = $false in the configuration file): the mailboxes are removed from Exchange Online without checking that the retention policy holds them.' + return + } + $context.CurrentOperation = 'Check-Retention'; $context.CurrentIdentity = '' + $rows = New-Object 'Collections.Generic.List[object]' + foreach ($plan in $Plans) { + if (Test-PraOrdinalEqual $plan.Operation 'AlreadyRecovered') { continue } + if (Test-PraRetentionCheckRecord -Record $plan.Row.BackupRec -PreserveCloudMailbox ([bool]$plan.Row.PreserveCloudMailbox)) { $rows.Add($plan.Row) } + } + if (-not $rows.Count) { + Write-PraItem -Context $context -Status Info -Icon Cloud -Text ('Retention: none of the {0} object(s) carries the retention tag, so there is no retention to check before the mailboxes are removed.' -f $Plans.Count) + return + } + $cloudNotDone = @() + try { + $doneInfo = Get-PraConvertCloudDone -Folder (Split-Path ([string]$context.Source.Path) -Parent) -BatchId ([string]$context.Source.Data.BatchId) -Environment ([string]$context.Config.Environment) + if ($null -ne $doneInfo -and $doneInfo.Known) { $cloudNotDone = @($rows | Where-Object { -not $doneInfo.Done.Contains([string]$_.ObjectGuid) }) } + } catch { $cloudNotDone = @() } + if ($cloudNotDone.Count) { + Write-PraItem -Context $context -Status Info -Icon Cloud -Text ('Retention: the Exchange Online part of the Convert is not recorded as complete for {0} of the {1} object(s) that carry the retention tag. They are checked like the others, on purpose: the licence group that the Convert adds gives a mailbox as soon as Entra Connect has synchronised, with or without that part, and the Recover removes the licence again. When Exchange Online has no mailbox for an object, the check says so (no mailbox, nothing to retain) and the Recover goes on.' -f $cloudNotDone.Count, $rows.Count) + } + $needGraph = -not (Test-PraOrdinalIgnoreCaseEqual ([string]$context.Config.Cloud.IdentityCheck) 'Off') + $report = Get-PraCloudModuleReport -MinExo ([string]$context.Config.Exo.MinModuleVersion) + $modulesOk = $report.Exo.Ok -and ($report.Graph.Ok -or -not $needGraph) + $isAd = (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'AD') + $certificate = [bool][string]$context.Config.Cloud.AppId + $canAsk = $modulesOk -and ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both') -or $certificate -or ($isAd -and (Test-PraRunCanSignIn))) + $script:RetentionProofReason = ''; $script:RetentionProofRoute = $false; $script:RetentionProof = $null; $script:RetentionProofMissing = @() + if ($canAsk) { + Import-Module (Join-Path $PSScriptRoot 'module\PRA.Cloud.psm1') -Force -ErrorAction Stop + $keepSession = $context.AllowMutation -and (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both') + $answer = Test-PraRetentionCoverage -Context $context -Rows $rows.ToArray() -CloseSession:(-not $keepSession) + } + else { + $unavailable = if (-not $modulesOk) { 'The cloud modules of this server cannot check the retention. ' + ($report.Messages -join ' ') } + else { 'This run cannot sign in to Exchange Online by itself: the configuration has no certificate sign-in (Cloud.AppId), and no person can answer a sign-in (-Force, or no interactive console).' } + $answer = [pscustomobject]@{ Checked = 0; Covered = 0; NoMailbox = 0; NoMailboxList = @(); NotCovered = @(); StopReason = $unavailable; CouldNotAsk = $true + Unverified = @(foreach ($row in $rows) { [pscustomobject]@{ ObjectGuid = [string]$row.ObjectGuid; Upn = [string]$row.UserPrincipalName; Reason = $unavailable } }) } + } + $context.CurrentOperation = 'Check-Retention'; $context.CurrentIdentity = '' + $notCovered = @($answer.NotCovered); $unverified = @($answer.Unverified) + $couldNotAsk = [bool](Get-PraValue $answer 'CouldNotAsk' $false) + $viaProof = $false; $coveredCount = [int](Get-PraValue $answer 'Covered' 0); $noMailboxCount = [int](Get-PraValue $answer 'NoMailbox' 0); $proofKinds = @{ Unverified = 0; NotChecked = 0; NotListed = 0 } + if ($isAd -and $couldNotAsk -and -not $notCovered.Count) { + $script:RetentionProofRoute = $true + $proof = Get-PraRetentionProof -Folder (Get-PraRetentionProofFolder) -BatchId ([string]$context.Source.Data.BatchId) -Environment ([string]$context.Config.Environment) -MaxAgeHours ([int]$context.Config.Retention.ProofMaxAgeHours) -Row $rows.ToArray() -SourceBackupHash ([string]$context.Source.Hash) -PolicyGuid ([string]$context.Config.Retention.PolicyGuid) + $script:RetentionProof = $proof + if ($proof.Found -and $proof.Complete) { + $item = $proof.Proofs[0] + $accepted = [pscustomobject]@{ Path = [string]$item.Path; Sha256 = [string]$item.Sha256; CreatedUtc = $item.CreatedUtc; PolicyGuid = [string[]]@($item.PolicyGuid); ObjectCount = [int]$item.ObjectCount } + $hours = ([DateTime]::UtcNow - $item.CreatedUtc).TotalHours.ToString('0.#', [Globalization.CultureInfo]::InvariantCulture) + $policyNamed = if ([string]$context.Config.Retention.PolicyGuid) { '' } else { ' (policy {0}, as the proof names it: Retention.PolicyGuid is not set on this server)' -f $(if (@($accepted.PolicyGuid).Count) { @($accepted.PolicyGuid) -join ', ' } else { 'none recorded' }) } + Write-PraItem -Context $context -Status Ok -Icon Cloud -Text ('Retention: accepted from the retention proof {0} ({1} hours old, written by a Check on the cloud server): the {2} object(s) that carry the retention tag are covered{3}' -f [IO.Path]::GetFileName($accepted.Path), $hours, $rows.Count, $policyNamed) + $detail = 'SHA-256 {0}, created {1} UTC, policy {2}, {3} object(s)' -f $accepted.Sha256, $accepted.CreatedUtc.ToString('yyyy-MM-dd HH:mm:ss', [Globalization.CultureInfo]::InvariantCulture), $(if (@($accepted.PolicyGuid).Count) { @($accepted.PolicyGuid) -join ', ' } else { '(none recorded)' }), $accepted.ObjectCount + $signInFailed = [bool](Get-PraValue $answer 'SignInFailed' $false) + Write-PraItem -Context $context -Status $(if ($signInFailed) { 'Warn' } else { 'Info' }) -Icon Cloud -Text ('Exchange Online could not be asked by this run: {0} The proof: {1}.' -f ([string]$answer.StopReason).Trim(), $detail) + $context.RetentionProofAccepted = [object[]]@($accepted) + Write-PraLog -Context $context -Message ('Retention proof accepted: {0} | SHA-256 {1} | created {2} UTC | policy {3} | {4} object(s) | live check: {5}' -f $accepted.Path, $accepted.Sha256, $accepted.CreatedUtc.ToString('yyyy-MM-dd HH:mm:ss', [Globalization.CultureInfo]::InvariantCulture), (@($accepted.PolicyGuid) -join ','), $accepted.ObjectCount, ([string]$answer.StopReason -replace '\s+', ' ')) -Level Detail + if ($proof.Duplicates) { Write-PraLog -Context $context -Message ('{0} copy(ies) of the retention proof were found in the folders and counted once' -f $proof.Duplicates) -Level Detail } + if ($AcceptRetentionRisk) { Write-PraItem -Context $context -Status Info -Icon Cloud -Text '-AcceptRetentionRisk was given and is not needed: the retention proof covers every mailbox.' } + Write-PraRetentionNoMailbox -Entry @($proof.NoMailbox) + return + } + $shownBlocked = 0 + $says = @{ NotCovered = 'says that the retention policy does not hold this mailbox'; Unverified = 'says that the retention of this mailbox could not be checked when the proof was written'; NotChecked = 'says that this mailbox was not checked when the proof was written (the Check stopped before it)'; NotListed = 'does not list this mailbox' } + foreach ($entry in @($proof.Blocked)) { + if ($shownBlocked -ge 10) { Write-PraLog -Context $context -Message ('{0}: the newest retention proof {1} {2}' -f $entry.Upn, $entry.Proof, $says[[string]$entry.Verdict]) -Level Detail; continue } + $context.CurrentIdentity = [string]$entry.ObjectGuid + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('{0}: the newest retention proof {1} {2}.' -f $entry.Upn, $entry.Proof, $says[[string]$entry.Verdict]) + $shownBlocked++ + } + $context.CurrentIdentity = '' + if (@($proof.Blocked).Count) { Write-PraItem -Context $context -Status Warn -Icon Cloud -Text 'Only the newest retention proof counts: an older proof never completes it.' } + $script:RetentionProofReason = if ($proof.Reason) { [string]$proof.Reason } else { 'no usable retention proof' } + if ($proof.Missing.Count) { Write-PraLog -Context $context -Message ('Retention proof {0}: not covered or not in it: {1}' -f [IO.Path]::GetFileName($proof.Path), ($proof.Missing -join ', ')) -Level Detail } + $script:RetentionProofMissing = @($proof.Blocked) + if ($proof.Found) { + # A proof that was read and does not cover every object is the answer: its verdicts are the counts and the words. + $viaProof = $true + $notCovered = @(@($proof.Blocked) | Where-Object { Test-PraOrdinalEqual ([string]$_.Verdict) 'NotCovered' } | ForEach-Object { [pscustomobject]@{ ObjectGuid = [string]$_.ObjectGuid; Upn = [string]$_.Upn; Reason = ('the newest retention proof {0} {1}' -f $_.Proof, $says['NotCovered']) } }) + $unverified = @(@($proof.Blocked) | Where-Object { -not (Test-PraOrdinalEqual ([string]$_.Verdict) 'NotCovered') } | ForEach-Object { [pscustomobject]@{ ObjectGuid = [string]$_.ObjectGuid; Upn = [string]$_.Upn; Reason = ('the newest retention proof {0} {1}' -f $_.Proof, $says[[string]$_.Verdict]) } }) + foreach ($kind in @('Unverified', 'NotChecked', 'NotListed')) { $proofKinds[$kind] = @(@($proof.Blocked) | Where-Object { Test-PraOrdinalEqual ([string]$_.Verdict) $kind }).Count } + $noMailboxCount = @($proof.NoMailbox).Count + $coveredCount = [Math]::Max(0, $rows.Count - @($proof.Blocked).Count - $noMailboxCount) + } + } + $withoutMailbox = if ($viaProof) { @($proof.NoMailbox) } else { Get-PraValue $answer 'NoMailboxList' @() } + Write-PraRetentionNoMailbox -Entry @($withoutMailbox) + $bad = $notCovered.Count + $unverified.Count + $without = if ($noMailboxCount) { ' ({0} without a mailbox in Exchange Online: nothing to retain, see the warnings above)' -f $noMailboxCount } else { '' } + if (-not $bad) { + Write-PraItem -Context $context -Status Ok -Icon Cloud -Text ('Retention: the retention policy holds the {0} mailbox(es) that carry the retention tag{1}' -f $coveredCount, $without) + if ($AcceptRetentionRisk) { Write-PraItem -Context $context -Status Info -Icon Cloud -Text '-AcceptRetentionRisk was given and is not needed: every mailbox is held.' } + return + } + $lines = New-Object 'Collections.Generic.List[string]' + foreach ($entry in $notCovered) { $lines.Add(('Retention not covered | {0} | {1}' -f $entry.Upn, $entry.Reason)) } + foreach ($entry in $unverified) { $lines.Add(('Retention not checked | {0} | {1}' -f $entry.Upn, $entry.Reason)) } + Write-PraLog -Context $context -Lines $lines.ToArray() -Level Detail + $shorten = { param([string]$Text) if ($Text.Length -gt 300) { $Text.Substring(0, 300) + '...' } else { $Text } } + $limit = 10; $shown = 0 + # The mailboxes concerned are named in the warning: the first ten, then how many more (the full list is in the log). + $namesOf = { param($Items) $names = @(@($Items) | ForEach-Object { [string]$_.Upn }); $text = (@($names | Select-Object -First 10) -join ', '); if ($names.Count -gt 10) { $text += (' and {0} more (the full list is in the log)' -f ($names.Count - 10)) }; $text } + if (-not $viaProof) { + foreach ($entry in $notCovered) { + if ($shown -ge $limit) { break } + $context.CurrentIdentity = [string]$entry.ObjectGuid + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('{0}: the retention policy does not hold this mailbox. {1}' -f $entry.Upn, (& $shorten ([string]$entry.Reason))) + $shown++ + } + } + $context.CurrentIdentity = '' + if ($viaProof) { + if ([string]$answer.StopReason) { Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('Exchange Online could not be asked by this run ({0}), so the newest retention proof was read.' -f (& $shorten (([string]$answer.StopReason).Trim().TrimEnd('.')))) } + } + elseif ([string]$answer.StopReason) { + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('The retention of {0} mailbox(es) could not be checked: {1}' -f $unverified.Count, (& $shorten ([string]$answer.StopReason))) + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('Mailboxes concerned ({0}): {1}.' -f $unverified.Count, (& $namesOf $unverified)) + } + else { + foreach ($entry in $unverified) { + if ($shown -ge $limit) { break } + $context.CurrentIdentity = [string]$entry.ObjectGuid + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('{0}: the retention of this mailbox could not be checked. {1}' -f $entry.Upn, (& $shorten ([string]$entry.Reason))) + $shown++ + } + $context.CurrentIdentity = '' + } + if ($bad -gt $shown -and -not $viaProof -and -not [string]$answer.StopReason) { Write-PraItem -Context $context -Status Info -Icon Cloud -Text ('{0} more mailbox(es) are listed in the log.' -f ($bad - $shown)) } + if ($viaProof) { + $kinds = '' + if ($proofKinds.Unverified) { $kinds += (', {0} unverified (the Check could not check them)' -f $proofKinds.Unverified) } + if ($proofKinds.NotChecked) { $kinds += (', {0} not checked (the Check stopped before them)' -f $proofKinds.NotChecked) } + if ($proofKinds.NotListed) { $kinds += (', {0} not in the proof' -f $proofKinds.NotListed) } + $summary = '{0} mailbox(es) held, {1} not held by the retention policy{2}{3}' -f $coveredCount, $notCovered.Count, $kinds, $without + } + else { $summary = '{0} mailbox(es) held, {1} not held by the retention policy, {2} not checked{3}' -f $coveredCount, $notCovered.Count, $unverified.Count, $without } + if ($script:RetentionProofRoute) { Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('No retention proof stands in for the check: {0}.' -f $script:RetentionProofReason) } + if ($AcceptRetentionRisk) { + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('Retention risk accepted for this run (-AcceptRetentionRisk). {0}. The {1} mailbox(es) that are not held or not checked are removed from Exchange Online without a retention hold of the policy.' -f $summary, $bad) + $context.ConfigOverrides = @(@(Get-PraList $context 'ConfigOverrides') + ('Retention check before Recover: {0} mailbox(es) not held or not checked, accepted for this run (-AcceptRetentionRisk)' -f $bad)) + return + } + $shortBatch = Get-PraShortId ([string]$context.Source.Data.BatchId) + $check = (Get-PraCommandLine -ActionName 'Check' -ModeName 'Preview' -BatchId $shortBatch -OtherServer:$script:RetentionProofRoute) + ' -Expect Retained' + $typedBatch = if ($script:PreviewPackage) { $script:PreviewPackage } elseif ($script:PackageArgument) { $script:PackageArgument } else { $Batch } + $again = Get-PraCommandLine -ActionName 'Recover' -PhaseName $(if ($Phase) { $Phase } else { '' }) -ModeName 'Preview' -BatchId $typedBatch -KeepFilters + $anyway = (Get-PraCommandLine -ActionName 'Recover' -PhaseName $(if ($Phase) { $Phase } else { '' }) -ModeName 'Apply' -BatchId $typedBatch -KeepFilters) + ' -AcceptRetentionRisk' + $refusal = if ($script:RetentionProofRoute -and $null -ne $script:RetentionProof) { [string]$script:RetentionProof.Refusal } else { '' } + $proofRoute = [bool]($script:RetentionProofRoute -and $null -ne $script:RetentionProof) + $proofPolicy = if ($proofRoute) { (@($script:RetentionProof.PolicyGuid) -join ', ') } else { '' } + if (-not $proofPolicy) { $proofPolicy = 'none recorded' } + $damagedPath = if ($proofRoute) { [string](Get-PraValue $script:RetentionProof 'RefusedPath' '') } else { '' } + $inboxFolder = Join-Path $context.BackupFolder 'Inbox' + $policyName = [string]$context.Config.Retention.PolicyName + $lookup = if ($policyName) { 'Connect-IPPSSession; (Get-RetentionCompliancePolicy -Identity {0}).Guid' -f (ConvertTo-PraLiteral $policyName) } else { 'Connect-IPPSSession; Get-RetentionCompliancePolicy | Format-Table Name,Guid' } + if (-not $context.AllowMutation) { + Write-PraItem -Context $context -Status Warn -Icon Cloud -Text ('{0}. The Apply will be refused as things stand.' -f $summary) + $blocker = if ($proofRoute -and (Test-PraOrdinalEqual $refusal 'CopyAgain')) { 'copy both files of the newest retention proof again from the Backups\Outbox folder of the cloud server to {0}{1} ({2}); an older proof never stands in for it, and run the Check again on the cloud server if the files are damaged at the source ({3}), or add -AcceptRetentionRisk to the Apply command to go on anyway for this one run' -f $inboxFolder, $(if ($damagedPath) { ', and delete the damaged copy at ' + $damagedPath } else { '' }), $script:RetentionProofReason, $check } + elseif ($proofRoute -and (Test-PraOrdinalEqual $refusal 'Clock')) { 'compare the clocks of the two servers (Get-Date on each: the newest retention proof is dated in the future), then run the Check again on the cloud server ({0}), or add -AcceptRetentionRisk to the Apply command to go on anyway for this one run' -f $check } + elseif ($proofRoute -and (Test-PraOrdinalEqual $refusal 'PolicyMismatch')) { 'align Retention.PolicyGuid on the two servers (the newest retention proof names the policy {0}, this server has {1}; read the GUID with: {2}), then run the full Check again on the cloud server ({3}), or add -AcceptRetentionRisk to the Apply command to go on anyway for this one run' -f $proofPolicy, [string]$context.Config.Retention.PolicyGuid, $lookup, $check } + elseif ($proofRoute -and (Test-PraOrdinalEqual $refusal 'PolicyGuid')) { 'correct Retention.PolicyGuid in the configuration file (it is not a GUID; read the GUID with: {0}), or add -AcceptRetentionRisk to the Apply command to go on anyway for this one run' -f $lookup } + else { 'make the retention policy hold the mailboxes named above (see them with: {0}{1}), or add -AcceptRetentionRisk to the Apply command to go on anyway for this one run' -f $check, $(if ($script:RetentionProofRoute) { ', on the cloud server' } else { '' }) } + $context.ApplyBlockers = @(Get-PraList $context 'ApplyBlockers') + $blocker + return + } + $steps = @() + if (-not [string]$context.Config.Retention.PolicyGuid) { + $steps += 'The retention policy is not named in the configuration file. Read its GUID in a Security and Compliance session, then put it in Retention.PolicyGuid:' + $steps += $lookup + } + $configuredGuid = [string]$context.Config.Retention.PolicyGuid; $parsedGuid = [guid]::Empty + if ($configuredGuid -and (-not [guid]::TryParse($configuredGuid, [ref]$parsedGuid) -or $parsedGuid -eq [guid]::Empty)) { + $steps += ('Retention.PolicyGuid in the configuration file ({0}) is not a GUID. Read the GUID of the retention policy, then put it in Retention.PolicyGuid:' -f $configuredGuid) + $steps += $lookup + } + if ($proofRoute -and (Test-PraOrdinalEqual $refusal 'CopyAgain')) { + $steps += ('The newest retention proof cannot be used: {0}. Copy both files again, RetentionProof-...json and its .sha256 file, from the Backups\Outbox folder of the cloud server to the folder {1} of this server (together, and wait for the copy to end), then run the Preview of the Recover again. An older proof never stands in for it.' -f $script:RetentionProofReason, $inboxFolder) + if ($damagedPath) { $steps += ('Before that, delete the damaged copy at {0} (and its .sha256 file), so that it is not read again.' -f $damagedPath) } + $steps += 'If the files are damaged at the source, run the Check again on the cloud server; it writes a new proof:' + $steps += $check + } + elseif ($proofRoute -and (Test-PraOrdinalEqual $refusal 'PolicyMismatch')) { + $steps += ('The newest retention proof, {0}, is of another retention policy: it names {1}, and Retention.PolicyGuid in the configuration file of this server is {2}. Make the two servers name the same policy: put the GUID of the policy that holds the mailboxes in Retention.PolicyGuid of the configuration file on the cloud server and on this server (read the GUID with the command below), then run the full Check again on the cloud server. An older proof never stands in for it.' -f [IO.Path]::GetFileName($damagedPath), $proofPolicy, [string]$context.Config.Retention.PolicyGuid) + $steps += $lookup + $steps += 'Then, on the cloud server, run the Check (read only); it writes a new proof:' + $steps += $check + $steps += ('Copy those two files to the folder {0} of this server, then run the Preview of the Recover again.' -f $inboxFolder) + } + elseif ($script:RetentionProofRoute) { + $steps += 'This server could not ask Exchange Online, and no retention proof stands in for it. On the cloud server, with the batch folder there, make the retention policy hold the mailboxes named above (an adaptive scope can take several days), then run the Check (read only). It writes a retention proof, RetentionProof-...json and its .sha256 file, in the Backups\Outbox folder of that server:' + if (@($script:RetentionProofMissing).Count) { $steps += ('The newest retention proof, {0}, does not cover {1} object(s) of this Recover (for example {2}). Only the newest proof counts: run the full Check again on the cloud server, after the policy holds those mailboxes; it writes a new proof for every object.' -f $script:RetentionProofMissing[0].Proof, @($script:RetentionProofMissing).Count, ((@($script:RetentionProofMissing | Select-Object -First 3 | ForEach-Object { [string]$_.Upn }) -join ', '))) } + $steps += $check + $steps += ('Copy those two files to the folder {0} of this server, then run the Preview of the Recover again. This server accepts a proof for as many hours as its own Retention.ProofMaxAgeHours says ({1}).' -f (Join-Path $context.BackupFolder 'Inbox'), $context.Config.Retention.ProofMaxAgeHours) + $steps += ('Why no proof was accepted: {0}.' -f $script:RetentionProofReason) + if ($null -ne $script:RetentionProof -and [bool](Get-PraValue $script:RetentionProof 'FutureDated' $false)) { + $steps += 'A proof is dated in the future: the clocks of the two servers differ. Compare them: run Get-Date on each server, or run on this server (replace by its name): w32tm /stripchart /computer: /samples:3 /dataonly. Fix the clock of the server that is wrong (domain time: w32tm /resync), then write the proof again with the Check above.' + } + } + else { + $steps += 'Make the retention policy hold the mailboxes named above (an adaptive scope can take several days). To see what Exchange Online says about each mailbox, run the Check (read only):' + $steps += $check + } + $steps += 'Then run the Preview of the Recover again:' + $steps += $again + $steps += 'To turn this check off for every run, set Retention.CheckBeforeRecover = $false in the configuration file (not recommended).' + $steps += 'To go on anyway, for this one run only (the mailboxes that are not held are removed without a retention hold of the policy), add -AcceptRetentionRisk to the Apply:' + $steps += $anyway + $context.NextSteps = $steps; $context.NextOnFailure = $true; $context.NoChangeMade = $true + throw ('Recover stopped before any change: the retention policy does not hold {0} mailbox(es) and {1} could not be checked ({2} object(s) carry the retention tag). Nothing was changed.' -f $notCovered.Count, $unverified.Count, $rows.Count) +} + function Confirm-PraApply { <# .SYNOPSIS @@ -776,6 +1164,224 @@ function Send-PraPlanCount { Write-PraEvent -Kind count -Data @{ count = $Count; stepIds = $ids } } +function Set-PraRowsAwaitCloud { + <# Phase Both: the AD part is verified and the Exchange Online part is still to come. The objects are Pending until the cloud part confirms them. #> + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'Changes the status of the in-memory result rows only.')] + param() + foreach ($row in $context.Rows) { + if ((Test-PraOrdinalIn ([string]$row.FinalStatus) @('Success', 'AlreadyDone'))) { $row.FinalStatus = 'Pending' } + } +} + +function Assert-PraBatchNotRolledBack { + <# A Convert batch that a Recover batch rolled back, or started to roll back, cannot be resumed: its objects are not converted any more (or not for certain), and a resume would hand over, or grant permissions, for a batch whose conversion is undone. #> + param([Parameter(Mandatory)][string[]]$ObjectGuid) + $recover = Find-PraRecoverOfBatch -Context $context -SourceHash ([string]$context.Source.Hash) -ObjectGuid $ObjectGuid + if ($null -eq $recover) { return } + $short = Get-PraShortId ([string]$context.Source.Data.BatchId) + $check = (Get-PraCommandLine -ActionName 'Check' -ModeName 'Preview' -BatchId $recover.ShortId) -replace '^(\.\\Invoke-PraRemoteMailbox\.ps1 -Action Check -Batch [0-9a-fA-F]+)', '$1 -Expect Deprovisioned' + $what = if (Test-PraOrdinalEqual $recover.Basis 'State') { 'already rolled back objects of it' } + elseif (Test-PraOrdinalEqual $recover.Basis 'Journal') { 'started to roll back objects of it (it stopped before its proof)' } + elseif (Test-PraOrdinalEqual $recover.Basis 'Damaged') { 'was started on it and its journal has lines that cannot be read: every object counts as rolled back' } + else { 'was started on it and its journal is not here: every object counts as rolled back' } + $steps = @(('Batch {0} was rolled back by Recover batch {1}: its objects are not converted any more. To check what the rollback left, run:' -f $short, $recover.ShortId), $check) + if (-not (Test-PraOrdinalEqual $recover.Basis 'State')) { + $steps = @(('Recover batch {1} {2}. To see what is left, run:' -f $short, $recover.ShortId, $what), $check, + ('To finish the rollback of batch {0}, run the Preview of the Recover (then the same command with -Mode Apply):' -f $short), (Get-PraCommandLine -ActionName 'Recover' -ModeName 'Preview' -BatchId $short)) + } + $context.NextSteps = $steps + @('To convert objects again, start a new Convert (run its Preview first):', (Get-PraCommandLine -ActionName 'Convert' -PhaseName 'AD' -ModeName 'Preview' -KeepFilters)) + $context.NextOnFailure = $true; $context.NoChangeMade = $true; $context.CurrentIdentity = '' + throw ('Convert batch {0} cannot be resumed: Recover batch {1} {2}. Nothing was changed.' -f $short, $recover.ShortId, $what) +} + +function Get-PraBatchTouchedSet { + <# The objects that the journal of the Convert batch in $context.Source shows as written or about to be written. #> + $journal = Join-Path (Split-Path $context.Source.Path -Parent) ('Journal-' + [string]$context.Source.Data.BatchId + '.jsonl') + $skipped = 0 + $set = Get-PraJournalTouchedObject -Path $journal -Context $context -SkippedCount ([ref]$skipped) + $script:TouchedSkipped = $skipped + return , $set +} + +function Get-PraPartialSourceProof { + <# The AD proof of the Convert batch in $context.Source when it is marked partial (checked in full), else $null. A batch without a State file is not partial for this purpose. + A State file that cannot be read, or that fails its checks (missing or wrong .sha256, damaged content), gives Unusable = $true with the Reason: the caller falls back to the journal. #> + $path = Join-Path (Split-Path $context.Source.Path -Parent) ('State-' + [string]$context.Source.Data.BatchId + '.json') + if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { return $null } + try { $raw = [IO.File]::ReadAllText($path) | ConvertFrom-PraJson } catch { return [pscustomobject]@{ Unusable = $true; Reason = 'the State file cannot be read' } } + if ($null -eq $raw -or $null -eq (Get-PraValue $raw 'Kind' $null)) { return [pscustomobject]@{ Unusable = $true; Reason = 'the State file is not an AD proof' } } + if ((Get-PraValue $raw 'Partial' $false) -ne $true) { return $null } + try { return (Import-PraProof $context $path $context.Source 'Convert') } + catch { return [pscustomobject]@{ Unusable = $true; Reason = (([string]$_.Exception.Message -split '\r?\n')[0]).Trim() } } +} + +function Set-PraUnprovenRow { + <# + .SYNOPSIS + A record of a partial batch that its AD proof does not list: the batch stopped on it after a write was started (it may be partly changed: Pending, to roll back), + or never reached it (Skipped, nothing was written). Either way it leaves this run. + #> + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'Changes the status of an in-memory result row only.')] + param([Parameter(Mandatory)]$Row, [Parameter(Mandatory)]$Record, [Parameter(Mandatory)][string]$Reason) + $guid = [string]$Record.ObjectGuid + $Row.ADApplied = $false; $Row.ADVerified = $false + if ($script:Touched.Contains($guid)) { + $Row.FinalStatus = 'Pending' + $Row.Detail = 'may be partly changed: the batch stopped on this object after a write was started; roll the batch back (Recover) to restore it' + [void]$script:MayBeChanged.Add($guid) + $text = 'may be partly changed (the batch stopped on it after a write was started)'; $status = 'Warn' + } + else { + $Row.FinalStatus = 'Skipped'; $Row.Detail = 'not converted by this batch: it stopped at its first error before this object, nothing was written to it' + $text = $Reason; $status = 'Skip' + } + $context.Rows.Add($Row); [void]$script:NotConverted.Add($guid) + $context.CurrentIdentity = $guid + Write-PraItem -Context $context -Status $status -Text $text + $context.CurrentIdentity = '' +} + +function New-PraPartialContinuation { + <# What the Next steps need of a partial batch that this run leaves partly out: who was not converted, who may be partly changed, who can be written in a CSV. #> + param([Parameter(Mandatory)][string]$Side, [Parameter(Mandatory)][int]$Verified) + $left = @($context.Rows | Where-Object { $script:NotConverted.Contains([string]$_.ObjectGuid) -and -not $script:MayBeChanged.Contains([string]$_.ObjectGuid) }) + $maybe = @($context.Rows | Where-Object { $script:MayBeChanged.Contains([string]$_.ObjectGuid) }) + $ids = New-Object 'Collections.Generic.List[string]' + foreach ($row in $left) { foreach ($value in @([string]$row.SamAccountName, [string]$row.UserPrincipalName, [string]$row.ObjectGuid, [string](Get-PraValue $row.BackupRec 'DistinguishedName' ''))) { if ($value) { $ids.Add($value) } } } + return [pscustomobject]@{ ShortId = $context.BatchId; Verified = $Verified; Complete = $false; Side = $Side + NotConverted = [string[]]@($left | ForEach-Object { [string]$_.SamAccountName }); NotConvertedIdentifiers = [string[]]$ids.ToArray(); MayBeChanged = [string[]]@($maybe | ForEach-Object { [string]$_.SamAccountName }) } +} + +function ConvertTo-PraIdentityKey { + <# The key an identity is matched by: a GUID in any form (braces, no dashes, any case) is its 32 lower-case digits, any other text is itself (the comparison ignores the case). #> + param([AllowNull()][string]$Value) + $text = ([string]$Value).Trim() + $guid = [guid]::Empty + if ($text -and [guid]::TryParse($text, [ref]$guid)) { return $guid.ToString('N') } + return $text +} + +function Write-PraRemainingCsv { + <# + .SYNOPSIS + A CSV of the objects that are still to convert, to give to a new Convert (-CsvPath): the lines of the CSV of this run that name them, with the same columns, or one + Identity column. Written in the log folder (private). Returns its path, or '' when there is nothing to write or the file cannot be written. + #> + param([Parameter(Mandatory)]$Partial) + $names = @($Partial.NotConverted) + if (-not $names.Count -or (Test-PraOrdinalEqual $Partial.Side 'Cloud')) { return '' } + $folder = [string]$context.LogFolder + if (-not $folder -or -not (Test-Path -LiteralPath $folder -PathType Container)) { return '' } + $source = '' + if (Test-PraOrdinalEqual $Partial.Side 'Run') { + $source = if ($CsvPath) { $CsvPath } elseif ((Test-PraOrdinalIgnoreCaseEqual ([string](Get-PraValue (Get-PraValue $context.Config 'Scope' @{}) 'Mode' '')) 'Csv')) { [string](Get-PraValue $context.Config.Scope 'CsvPath' '') } else { '' } + if (-not $source) { return '' } + } + try { + $delimiter = ',' + if ($source) { + $text = Read-PraCsvText -Path $source + $header = ($text -split '\r?\n', 2)[0] + $delimiter = if ($header -match '(?i)(^|,)\s*"?Identity"?\s*(,|$)') { ',' } else { ';' } + $rows = @(ConvertFrom-Csv -InputObject $text -Delimiter $delimiter -ErrorAction Stop) + $wanted = New-Object 'Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase) + foreach ($id in @($Partial.NotConvertedIdentifiers)) { [void]$wanted.Add((ConvertTo-PraIdentityKey $id)) } + $converted = New-Object 'Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase) + foreach ($row in @($context.Rows | Where-Object { -not $script:NotConverted.Contains([string]$_.ObjectGuid) })) { + foreach ($value in @([string]$row.SamAccountName, [string]$row.UserPrincipalName, [string]$row.ObjectGuid, [string](Get-PraValue $row.BackupRec 'DistinguishedName' ''))) { if ($value) { [void]$converted.Add((ConvertTo-PraIdentityKey $value)) } } + } + $keep = New-Object 'Collections.Generic.List[object]'; $unknown = New-Object 'Collections.Generic.List[string]'; $leftOut = 0 + foreach ($row in $rows) { + $key = ConvertTo-PraIdentityKey ([string](Get-PraValue $row 'Identity' '')) + if ($wanted.Contains($key)) { $keep.Add($row) } + elseif ($converted.Contains($key)) { $leftOut++ } + else { $keep.Add($row); $unknown.Add([string](Get-PraValue $row 'Identity' '')) } + } + if ($unknown.Count) { Write-PraItem -Context $context -Status Warn -Text ('{0} line(s) of the file {1} name no object of batch {2} ({3}): they are kept in the new file, check them.' -f $unknown.Count, $source, $Partial.ShortId, (($unknown | Select-Object -First 5) -join ', ')) } + if ($leftOut) { Write-PraItem -Context $context -Status Info -Text ('{0} line(s) of the file {1} name objects that batch {2} converted or stopped on: they are left out of the new file.' -f $leftOut, $source, $Partial.ShortId) } + if (-not $keep.Count) { return '' } + $columns = @($rows[0].PSObject.Properties.Name) + } + else { $keep = @($names | ForEach-Object { [pscustomobject]@{ Identity = $_ } }); $columns = @('Identity') } + $quote = { param($value) '"' + ([string]$value).Replace('"', '""') + '"' } + $lines = New-Object 'Collections.Generic.List[string]' + $lines.Add((($columns | ForEach-Object { & $quote $_ }) -join $delimiter)) + foreach ($row in $keep) { $lines.Add((($columns | ForEach-Object { & $quote (Get-PraValue $row $_ '') }) -join $delimiter)) } + $path = Join-Path $folder ('ToConvert-{0}-{1}.csv' -f $Partial.ShortId, $context.RunId.Substring(0, 15)) + Write-PraImmutableFile $path (($lines -join "`r`n") + "`r`n") + return $path + } + catch { return '' } +} + +function Get-PraPartialRestStep { + <# The objects that a partial Convert batch did not convert: how to convert them (a CSV of those only), what to do about the objects that may be partly changed, how to undo the batch. #> + param([Parameter(Mandatory)]$Partial) + $cloud = (Test-PraOrdinalEqual $Partial.Side 'Cloud') + $where = if ($cloud) { 'On the AD server: ' } else { '' } + $names = @($Partial.NotConverted); $shown = @($names | Select-Object -First 10) + $list = ($shown -join ', ') + $(if ($names.Count -gt $shown.Count) { ', and {0} more' -f ($names.Count - $shown.Count) } else { '' }) + $steps = @() + if ($names.Count) { + $csv = Write-PraRemainingCsv $Partial + if ($csv) { + $steps += ('{0} object(s) were not converted by batch {1} (it stopped at its first error, nothing was written to them): {2}. To convert them, fix the problem named by that error, then run a new Convert with the file {3}, which lists only them (run the Preview first):' -f $names.Count, $Partial.ShortId, $list, $csv) + $steps += (Get-PraCommandLine -ActionName 'Convert' -PhaseName 'AD' -ModeName 'Preview' -KeepFilters:(Test-PraOrdinalEqual $Partial.Side 'Run') -CsvOverride $csv) + } + else { + $steps += ('{0}{1} object(s) were not converted by batch {2} (it stopped at its first error, nothing was written to them): {3}. To convert them, fix the problem named by that error, then run a new Convert for those objects only{4}; the converted ones are skipped or refused (run the Preview first):' -f $where, $names.Count, $Partial.ShortId, $list, $(if ($cloud) { ' (a CSV file with an Identity column that lists only them)' } else { '' })) + $steps += (Get-PraCommandLine -ActionName 'Convert' -PhaseName 'AD' -ModeName 'Preview' -KeepFilters:(Test-PraOrdinalEqual $Partial.Side 'Run') -OtherServer:$cloud) + } + } + $maybe = @($Partial.MayBeChanged) + if ($maybe.Count) { + $steps += ('{0}{1} object(s) may be partly changed: {2}. The batch stopped on them after a write was started, so they are not in the list above. Roll batch {3} back to restore them (its converted objects are restored too, the others are left as they are): run the Preview, then the same command with -Mode Apply:' -f $where, $maybe.Count, ($maybe -join ', '), $Partial.ShortId) + } + else { + $steps += ('{0}To undo batch {1} instead (its {2} converted object(s) are restored, the others are left as they are), run the Preview of the rollback, then the same command with -Mode Apply:' -f $where, $Partial.ShortId, $Partial.Verified) + } + $steps += (Get-PraCommandLine -ActionName 'Recover' -ModeName 'Preview' -BatchId $Partial.ShortId -OtherServer:$cloud) + return $steps +} + +function Get-PraPartialStopStep { + <# A Convert batch stopped after some objects were converted and verified: how to continue them, then how to convert the others, what to do about an object that may be partly changed, or how to undo the batch. #> + param([Parameter(Mandatory)]$Partial) + $both = (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both') + $what = if ($Partial.Complete) { 'All {1} object(s) are converted and verified (their AD proof is written) but the run stopped before it finished' } else { 'The batch stopped at its first error: {0} of {1} object(s) are converted and verified (their AD proof is written), the others were not converted by it' } + $steps = @((($what + '. What this run already did is kept. To continue the {0} converted object(s) ({2}; AD is not changed again):') -f $Partial.Verified, $Partial.Planned, $(if ($both) { 'Entra Connect synchronisation' } else { 'Entra Connect synchronisation, then the transfer package' })), + (Get-PraCommandLine -ActionName 'Convert' -PhaseName 'AD' -BatchId $Partial.ShortId)) + if ($both) { $steps += @('Then the Exchange Online part of those objects:', (Get-PraCommandLine -ActionName 'Convert' -PhaseName 'Cloud' -BatchId $Partial.ShortId)) } + if ($Partial.Complete) { return $steps } + return $steps + @(Get-PraPartialRestStep ([pscustomobject]@{ ShortId = $Partial.ShortId; Verified = $Partial.Verified; NotConverted = $Partial.NotConverted; NotConvertedIdentifiers = $Partial.NotConvertedIdentifiers; MayBeChanged = $Partial.MayBeChanged; Side = 'Run' })) +} + +function Initialize-PraGrantSetting { + <# + .SYNOPSIS + The shared mailbox permissions that the cloud phase of a Convert batch grants follow the settings that the Convert run had: they are stored in the batch. + When this server's configuration differs, the batch values are used and a warning names them. A batch from an older version has none: this server's configuration is used, with a warning. + #> + # A Check of one account has no batch: this server's configuration decides. + if ($null -eq $context.Source) { return } + $sharedCount = @($context.Source.Data.Records | Where-Object { [bool](Get-PraValue $_ 'IsShared' $false) }).Count + $local = Get-PraValue $context.Config 'SharedMailbox' @{} + $names = @('Enabled', 'PermissionSource', 'GrantFullAccess', 'GrantSendAs', 'GrantSendOnBehalf') + $stored = Get-PraValue $context.Source.Data 'GrantSettings' $null + if ($null -eq $stored) { + $context.GrantSettingsSource = 'Configuration' + if ($sharedCount) { Write-PraItem -Context $context -Status Warn -Text ('This batch was written by an older version: it does not record the shared mailbox permission settings, so the configuration of this server decides ({0}).' -f (($names | ForEach-Object { '{0} = {1}' -f $_, (Get-PraValue $local $_ '') }) -join ', ')) } + return + } + $context.GrantSettingsSource = 'Batch' + $context.BatchGrantSettings = @{} + foreach ($name in $names) { $context.BatchGrantSettings[$name] = Get-PraValue $stored $name $null } + $different = @($names | Where-Object { -not (Test-PraOrdinalIgnoreCaseEqual ([string](Get-PraValue $stored $_ '')) ([string](Get-PraValue $local $_ ''))) }) + if ($different.Count -and $sharedCount) { + Write-PraItem -Context $context -Status Warn -Text ('The shared mailbox permission settings of this server differ from the ones of the batch ({0}). The batch values are used: {1}.' -f (($different | ForEach-Object { '{0}: batch {1}, this server {2}' -f $_, (Get-PraValue $stored $_ ''), (Get-PraValue $local $_ '') }) -join '; '), (($names | ForEach-Object { '{0} = {1}' -f $_, (Get-PraValue $stored $_ '') }) -join ', ')) + } +} + function Get-PraSkipReason { param([bool]$HasWork = $true) if (-not $HasWork) { return 'Nothing to do.' } @@ -791,9 +1397,18 @@ $script:PreviewPackage = '' $script:PackageArgument = '' $script:ImportedFolders = @() $script:ConfirmBound = $PSBoundParameters.ContainsKey('Confirm') +# The objects of a partial Convert batch that this run leaves out (not converted by that batch), and what the Next steps need to name them. +$script:NotConverted = New-Object 'Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase) +$script:PartialContinuation = $null +# The objects that the journal of a partial batch shows as written or about to be written, those among them that the batch did not verify, and whether the proof of the source is partial. +$script:Touched = New-Object 'Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase) +$script:TouchedSkipped = 0 +$script:MayBeChanged = New-Object 'Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase) +$script:SourcePartial = $false # Known from the start; the run sets it from the configuration. $effectivePhase = [string]$Phase try { + $context.RunReachedEnd = $false # --------------------------------------------------------------------------------------------- # Configuration, audit files, banner. # --------------------------------------------------------------------------------------------- @@ -868,6 +1483,9 @@ try { foreach ($difference in $configDifferences) { Write-PraItem -Context $context -Status Info -Icon Config -Text ('Run setting: {0} {1} (configuration file: {2})' -f $difference.Key, $(if ($difference.Effective) { $difference.Effective } else { '(empty)' }), $(if ($difference.Base) { $difference.Base } else { '(empty)' })) } + if ($AcceptRetentionRisk -and -not ((Test-PraOrdinalIgnoreCaseEqual $Action 'Recover') -and (Test-PraOrdinalIn $effectivePhase @('Both','AD') -IgnoreCase))) { + Write-PraItem -Context $context -Status Warn -Text '-AcceptRetentionRisk only applies to the Active Directory part of a Recover (-Phase Both or AD): it is ignored in this run.' + } # Steps of this run (numbered x/total in the console). $steps = switch ($Action) { @@ -929,8 +1547,14 @@ try { if (-not (Test-PraOrdinalIgnoreCaseEqual $effectiveMode 'Apply')) { $script:PreviewPackage = [string]$Batch } $imported = Import-PraTransferPackage -Path $packagePath -BackupFolder $importRoot -Environment $config.Environment -ExpectedKind $expectedKind Write-PraItem -Context $context -Status Ok -Icon Batch -Text ('Transfer package {0} verified (checksums, Environment, names): {1} folder(s) extracted, {2} already present and identical' -f $imported.Name, $imported.Created.Count, $imported.Existing.Count) - if ((-not (Test-PraOrdinalIgnoreCaseEqual $effectiveMode 'Apply'))) { Write-PraItem -Context $context -Status Info -Text 'Preview: the package was verified and read from a private temporary folder, deleted at the end. Nothing was written to the backup folder.' } + if ((-not (Test-PraOrdinalIgnoreCaseEqual $effectiveMode 'Apply'))) { Write-PraItem -Context $context -Status Info -Text ('Preview: the package was verified and read from a private temporary folder, deleted at the end. Nothing was written to the backup folder' + $(if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Check') -and (Test-PraOrdinalIgnoreCaseEqual $Expect 'Retained')) { ' except the retention proof, which is written to the Outbox folder of the backup folder.' } else { '.' })) } $script:ImportedFolders = @($imported.Created) + if ((Test-PraOrdinalIgnoreCaseEqual $effectiveMode 'Apply')) { + # The console tells an imported batch from one converted here by this file (outside the batch folder, which travels with the package). + $markerFolder = Join-Path $importRoot 'Imported' + Initialize-PraPrivateFolder -Path $markerFolder + [IO.File]::WriteAllText((Join-Path $markerFolder (([string]$imported.BatchId).ToLowerInvariant() + '.txt')), ('{0} {1}' -f $imported.Name, [DateTime]::UtcNow.ToString('o')), (New-Object Text.UTF8Encoding($false))) + } $Batch = [string]$imported.BatchId if ($PSBoundParameters.ContainsKey('Batch')) { $PSBoundParameters['Batch'] = $Batch } } @@ -985,17 +1609,33 @@ try { if ($context.Source.Legacy) { throw 'This batch was written by an old version and has no AD proof (State file): it cannot be finished from here. Nothing was changed.' } $batchFolder = Split-Path $context.Source.Path -Parent $proofPath = Join-Path $batchFolder ('State-' + $context.Source.Data.BatchId + '.json') - if (-not (Test-Path -LiteralPath $proofPath -PathType Leaf)) { throw 'This batch has no AD proof (State file): its AD changes were not verified, so it cannot be finished from here. Nothing was changed.' } + if (-not (Test-Path -LiteralPath $proofPath -PathType Leaf)) { + if (Test-PraOrdinalEqual (Get-PraBatchApplyState -Folder $batchFolder -BatchId ([string]$context.Source.Data.BatchId) -SchemaVersion ([int](Get-PraValue $context.Source.Data 'SchemaVersion' 2))) 'NotApplied') { + $short = Get-PraShortId ([string]$context.Source.Data.BatchId) + $context.NextSteps = @(('Nothing was written to Active Directory by batch {0}: its folder {1} holds the backup only (no AD proof, no journal line of a write), because the run that made it stopped before its first write. You can delete that folder, or keep it as evidence. It is not a batch to finish.' -f $short, $batchFolder), + 'To convert the objects, run the Convert again with the same selection (-Group, -SearchBase, -CsvPath or -Identity), the Preview first:', + (Get-PraCommandLine -ActionName 'Convert' -PhaseName 'AD' -ModeName 'Preview')) + $context.NextOnFailure = $true; $context.NoChangeMade = $true; $context.CurrentIdentity = '' + throw ('Batch {0} did not change Active Directory (it stopped before its first AD write), so there is nothing to finish. Nothing was changed.' -f $short) + } + throw 'This batch has no AD proof (State file): its AD changes were not verified, so it cannot be finished from here. Nothing was changed.' + } $context.SourceBackupHash = $context.Source.Hash $context.Proof = Import-PraProof $context $proofPath $context.Source 'Convert' + Assert-PraBatchNotRolledBack -ObjectGuid @($context.Proof.Data.Records | ForEach-Object { [string]$_.ObjectGuid }) $context.BatchId = Get-PraShortId ([string]$context.Source.Data.BatchId) $context.PhaseFolders = @($batchFolder) # The preflight runs before any object is marked: a refused run has touched nothing and must not show objects as done. Test-PraSyncAvailable + if ($context.Proof.Partial) { $script:Touched = Get-PraBatchTouchedSet } + $provenIndex = Get-PraRecordIndex $context.Proof.Data.Records foreach ($record in @($context.Source.Data.Records)) { - if (@($context.Proof.Data.Records | Where-Object { Test-PraOrdinalIgnoreCaseEqual $_.ObjectGuid $record.ObjectGuid }).Count -ne 1) { throw "Object not verified by the AD phase of this batch: $($record.SamAccountName). The batch cannot be finished from here. Nothing was changed." } + $provenCount = if ($null -eq (Find-PraRecord $provenIndex ([string]$record.ObjectGuid))) { 0 } elseif ($provenIndex.Duplicates.Contains([string]$record.ObjectGuid)) { 2 } else { 1 } + if ($provenCount -ne 1 -and -not ($context.Proof.Partial -and $provenCount -eq 0)) { throw "Object not verified by the AD phase of this batch: $($record.SamAccountName). The batch cannot be finished from here. Nothing was changed." } $row = New-PraRow $context $record - $row.ADVerified = $true; $row.ADApplied = $true; $row.BackupPath = $context.Proof.Receipt.Path + $row.BackupPath = $context.Proof.Receipt.Path + if ($provenCount -eq 0) { Set-PraUnprovenRow -Row $row -Record $record -Reason 'not converted by this batch (it stopped at its first error before this object)'; continue } + $row.ADVerified = $true; $row.ADApplied = $true $row.FinalStatus = if ($context.AllowMutation) { 'Success' } else { 'Planned' } $row.Detail = 'AD changes made and verified by an earlier run of this batch; they are not changed again.' $context.Rows.Add($row) @@ -1004,8 +1644,15 @@ try { Write-PraItem -Context $context -Status Info -Text 'AD changes made and verified by an earlier run of this batch; not changed again' $context.CurrentIdentity = '' } - Send-PraPlanCount $context.Rows.Count - Write-PraItem -Context $context -Status Ok -Text ("Batch {0}: {1} object(s), AD changes already made and verified (they are not changed again), backup and proof checked" -f $context.BatchId, $context.Rows.Count) + $convertedCount = $context.Rows.Count - $script:NotConverted.Count + Send-PraPlanCount $convertedCount + Write-PraItem -Context $context -Status Ok -Text ("Batch {0}: {1} object(s), AD changes already made and verified (they are not changed again), backup and proof checked" -f $context.BatchId, $convertedCount) + if ($script:NotConverted.Count) { + $script:PartialContinuation = New-PraPartialContinuation -Side 'AD' -Verified $convertedCount + $leftOut = $script:NotConverted.Count - $script:MayBeChanged.Count + if ($leftOut) { Write-PraItem -Context $context -Status Warn -Text ('{0} object(s) of this batch were not converted by it (it stopped at its first error): they are left out of this run, see the next steps.' -f $leftOut) } + if ($script:MayBeChanged.Count) { Write-PraItem -Context $context -Status Warn -Text ('{0} object(s) may be partly changed (the batch stopped on them after a write was started): {1}. Roll the batch back to restore them, see the next steps.' -f $script:MayBeChanged.Count, (@($script:PartialContinuation.MayBeChanged) -join ', ')) } + } if ($context.AllowMutation) { Confirm-PraApply ("Finish batch {0}? {1}A transfer package is written. AD is not changed again." -f $context.BatchId, $(if ($config.EntraConnect.Sync) { 'Entra Connect synchronises first. ' } else { '' })) $context.PhaseWriteFolder = $batchFolder @@ -1062,6 +1709,7 @@ try { $context.Proof = Import-PraProof $context $receipt.StatePath $receipt 'Convert' $context.BatchId = Get-PraShortId $receipt.Data.BatchId Invoke-PraSync $context + if ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both')) { Set-PraRowsAwaitCloud } # The Exchange Online part does not start when the synchronisation could not run: its mailboxes would not appear. The Next steps say how to go on. $runCloud = (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both') -and ($null -eq (Get-PraValue $context 'SyncFailure' $null)) if ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'AD')) { @@ -1085,9 +1733,57 @@ try { if ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both')) { Test-PraCloudModuleAvailable } $context.Source = Import-PraBackup $context (Get-PraBatchFile -Value $Batch -Operations @('Convert')) if (-not (Test-PraOrdinalEqual $context.Source.Data.Operation 'Convert')) { throw 'Recover needs the original Convert batch.' } + $applyState = Get-PraBatchApplyState -Folder (Split-Path $context.Source.Path -Parent) -BatchId ([string]$context.Source.Data.BatchId) -SchemaVersion ([int](Get-PraValue $context.Source.Data 'SchemaVersion' 2)) + if (Test-PraOrdinalEqual $applyState 'NotApplied') { + $leftover = Split-Path $context.Source.Path -Parent + $short = Get-PraShortId ([string]$context.Source.Data.BatchId) + $context.NextSteps = @(('Batch {0} did not change Active Directory: its folder {1} holds the backup only (no AD proof, no journal line of a write), because the run that made it stopped before its first write. You can delete that folder, or keep it as evidence. It is not a batch to roll back.' -f $short, $leftover), + 'To convert the objects, run the Convert again with the same selection (-Group, -SearchBase, -CsvPath or -Identity), the Preview first:', + (Get-PraCommandLine -ActionName 'Convert' -PhaseName 'AD' -ModeName 'Preview')) + $context.NextOnFailure = $true; $context.NoChangeMade = $true; $context.CurrentIdentity = '' + throw ('Recover stopped before any change: batch {0} did not change Active Directory (it stopped before its first AD write), so there is nothing to roll back.' -f $short) + } $context.SourceBackupHash = $context.Source.Hash $records = @(Select-PraSourceRecord $context.Source) $context.PhaseFolders = @(Split-Path $context.Source.Path -Parent) + # A Convert batch that stopped at its first error converted only some objects: the rollback takes those, and the object that the batch stopped on (it may be partly changed). + # The others were never touched by it, and may have been converted by another batch since: they are not rolled back. + $sourceProof = Get-PraPartialSourceProof + if ($null -ne $sourceProof) { + $script:Touched = Get-PraBatchTouchedSet + $proven = New-Object 'Collections.Generic.HashSet[string]' ([StringComparer]::OrdinalIgnoreCase) + if ([bool](Get-PraValue $sourceProof 'Unusable' $false)) { + # The proof cannot be trusted: the journal says which objects the batch may have changed, and those are rolled back. A named object (-Identity) is rolled back on its own. + $backupFolder = Split-Path $context.Source.Path -Parent + $short = Get-PraShortId ([string]$context.Source.Data.BatchId) + Write-PraItem -Context $context -Status Warn -Text ('The AD proof of batch {0} is marked partial but cannot be used ({1}): the journal of the batch decides which objects are rolled back.' -f $short, $sourceProof.Reason) + if (-not $Identity -and ($script:TouchedSkipped -gt 0 -or -not $script:Touched.Count)) { + $first = $records | Select-Object -First 1 + $journalDamaged = ($script:TouchedSkipped -gt 0) + $context.NextSteps = @(('The backup of batch {0} is {1}: it holds the original values of every object of the batch.' -f $short, $context.Source.Path), + 'If you know that an object was converted by this batch, roll it back on its own (run the Preview, then the same command with -Mode Apply):', + ((Get-PraCommandLine -ActionName 'Recover' -ModeName 'Preview' -BatchId $short) + ' -Identity ' + (ConvertTo-PraLiteral ([string](Get-PraValue $first 'SamAccountName' 'user')))), + 'Otherwise restore the attributes of the objects from that backup file by hand (the backups are the only way back), or copy the original State file and its .sha256 file back into the batch folder and run the same Recover again.') + if ($journalDamaged) { $context.NextSteps = @(('The journal of batch {0} has {1} line(s) that cannot be read: it may not name every object that the batch changed, so the rollback is not guessed.' -f $short, $script:TouchedSkipped)) + @($context.NextSteps) } + $context.NextOnFailure = $true; $context.NoChangeMade = $true; $context.CurrentIdentity = '' + if ($journalDamaged) { throw ('Recover of batch {0} cannot go on: its AD proof is partial but unusable ({1}) and {2} line(s) of its journal cannot be read, so the objects that the batch wrote cannot be told for certain. Nothing was changed.' -f $short, $sourceProof.Reason, $script:TouchedSkipped) } + throw ('Recover of batch {0} cannot go on: its AD proof is partial but unusable ({1}) and its journal lists no object that was written. Nothing was changed.' -f $short, $sourceProof.Reason) + } + if ($Identity) { foreach ($record in $records) { [void]$script:Touched.Add([string]$record.ObjectGuid) } } + } + else { foreach ($entry in @($sourceProof.Data.Records)) { [void]$proven.Add([string]$entry.ObjectGuid) } } + $taken = New-Object 'Collections.Generic.List[object]'; $left = New-Object 'Collections.Generic.List[object]' + foreach ($record in $records) { if ($proven.Contains([string]$record.ObjectGuid) -or $script:Touched.Contains([string]$record.ObjectGuid)) { $taken.Add($record) } else { $left.Add($record) } } + foreach ($record in $left) { + $row = New-PraRow $context $record + $row.FinalStatus = 'Skipped'; $row.Detail = 'not converted by this batch (it stopped at its first error before this object): nothing to roll back' + $context.Rows.Add($row); [void]$script:NotConverted.Add([string]$record.ObjectGuid) + $context.CurrentIdentity = [string]$record.ObjectGuid + Write-PraItem -Context $context -Status Skip -Text 'not converted by this batch: nothing to roll back' + $context.CurrentIdentity = '' + } + $records = $taken.ToArray() + } Send-PraPlanCount $records.Count Write-PraItem -Context $context -Status Ok -Text ("Convert batch {0}: {1} object(s) selected, backup and SHA-256 verified" -f (Get-PraShortId ([string]$context.Source.Data.BatchId)), $records.Count) Write-PraStep -Context $context -Title 'Active Directory connection' -Icon Directory @@ -1095,15 +1791,22 @@ try { Write-PraStep -Context $context -Title 'Planned restore' -Icon Plan $plans = @(foreach ($record in $records) { $operation = if ($record.IsShared -and -not $context.KeepCloudShared) { 'Deprovision' } else { 'Recover' } - New-PraPlan $context $record.ObjectGuid $operation $record + New-PraPlan $context $record.ObjectGuid $operation $record -CheckDrift }) if ($plans.Count) { $null = Show-PraPlanSummary $plans Invoke-PraAdPreview $context $plans } + $drifted = New-Object 'Collections.Generic.List[object]' + foreach ($plan in $plans) { if (@($plan.Drift).Count) { $drifted.Add($plan) } } + if ($drifted.Count) { + $context.CurrentOperation = 'Check-ObjectState'; $context.CurrentIdentity = '' + Write-PraItem -Context $context -Status Warn -Icon Plan -Text ('{0} of the {1} object(s) changed since this batch left them (named above): the saved values are put back over what is there now. Read their PLANNED values before the Apply.' -f $drifted.Count, $plans.Count) + } if ($plans.Count) { Test-PraSyncAvailable } + if ($plans.Count) { Invoke-PraRetentionGate $plans } if ($context.AllowMutation -and $plans.Count) { - Confirm-PraApply ("Roll back the {0} object(s) listed above? Users get their on-premises attributes back; shared mailboxes are first deprovisioned in Exchange Online." -f $plans.Count) + Confirm-PraApply ("Roll back the {0} object(s) listed above?{1} Users get their on-premises attributes back; shared mailboxes are first deprovisioned in Exchange Online." -f $plans.Count, $(if ($drifted.Count) { ' {0} of them changed since the batch left them: their current values are overwritten.' -f $drifted.Count } else { '' })) } if ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both')) { if ($context.AllowMutation -and $plans.Count) { @@ -1126,6 +1829,7 @@ try { $context.Proof = Import-PraProof $context $receipt.StatePath $context.Source 'Recover' $context.BatchId = Get-PraShortId $receipt.Data.BatchId Invoke-PraSync $context + if ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both')) { Set-PraRowsAwaitCloud } $runCloud = (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both') -and ($null -eq (Get-PraValue $context 'SyncFailure' $null)) if ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'AD')) { Write-PraStep -Context $context -Title 'Creating the transfer package' -Icon Batch @@ -1153,6 +1857,7 @@ try { Initialize-PraDirectory $context $user = Get-PraUser $context $Identity $record = [pscustomobject]@{ ObjectGuid = ([guid]$user.ObjectGUID).ToString(); SamAccountName = $user.SamAccountName; UserPrincipalName = $user.UserPrincipalName; IsShared = ((Test-PraOrdinalIn $user.msExchRecipientTypeDetails @(4, 34359738368) -IgnoreCase)) + SourceAnchor = [pscustomobject]@{ ObjectGuid = [string](ConvertTo-PraImmutableId -Value $user.ObjectGUID); ConsistencyGuid = [string](ConvertTo-PraImmutableId -Value (Get-PraValue $user 'mS-DS-ConsistencyGuid' $null)) } ExpectedX500 = [string[]]@(Get-PraExpectedX500 -LegacyExchangeDN ([string](Get-PraValue $user 'legacyExchangeDN' '')) -ProxyAddresses @($user.proxyAddresses)) } } $context.Rows.Add((New-PraRow $context $record)) @@ -1164,19 +1869,35 @@ try { $proofPath = '' if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Recover')) { $batchFile = Get-PraBatchFile -Value $Batch -Operations @('Recover','Convert') - $batchData = [IO.File]::ReadAllText($batchFile) | ConvertFrom-PraJson + $batchData = Get-PraJsonHeader $batchFile @('Operation', 'BatchId') if (Test-PraOrdinalEqual $batchData.Operation 'Recover') { $proofPath = Join-Path (Split-Path $batchFile -Parent) ('State-' + $batchData.BatchId + '.json') - $context.Source = Import-PraBackup $context (Find-PraConvertSource -Hash ([string]$batchData.SourceBackupHash)) + $context.Source = Import-PraBackup $context (Find-PraConvertSource -Hash ([string](Get-PraJsonHeader $batchFile @('SourceBackupHash')).SourceBackupHash)) $context.BatchId = Get-PraShortId $batchData.BatchId } elseif ($context.AllowMutation) { throw "Batch $Batch is a Convert batch: the cloud phase of a Recover needs the batch printed by its AD phase (it proves that AD was restored)." } else { $context.Source = Import-PraBackup $context $batchFile; $context.BatchId = Get-PraShortId $batchData.BatchId } } else { - $context.Source = Import-PraBackup $context (Get-PraBatchFile -Value $Batch -Operations @('Convert')) - $context.BatchId = Get-PraShortId ([string]$context.Source.Data.BatchId) - if (-not $context.Source.Legacy) { $proofPath = Join-Path (Split-Path $context.Source.Path -Parent) ('State-' + $context.Source.Data.BatchId + '.json') } + $isCheck = (Test-PraOrdinalIgnoreCaseEqual $Action 'Check') + $batchFile = Get-PraBatchFile -Value $Batch -Operations $(if ($isCheck) { @('Convert', 'Recover') } else { @('Convert') }) + $fromRecover = $false + if ($isCheck) { + # A Recover batch ID given to Check: the Convert batch that it rolled back is the source (as in the cloud phase of a Recover). + $batchData = Get-PraJsonHeader $batchFile @('Operation', 'BatchId') + if (Test-PraOrdinalEqual $batchData.Operation 'Recover') { + $fromRecover = $true + $context.Source = Import-PraBackup $context (Find-PraConvertSource -Hash ([string](Get-PraJsonHeader $batchFile @('SourceBackupHash')).SourceBackupHash)) + $context.BatchId = Get-PraShortId ([string]$batchData.BatchId) + Write-PraItem -Context $context -Status Info -Text ('Batch {0} is a Recover batch: the Convert batch {1} that it rolled back is checked.' -f $context.BatchId, (Get-PraShortId ([string]$context.Source.Data.BatchId))) + if (-not (Test-PraOrdinalIgnoreCaseEqual $Expect 'Deprovisioned')) { Write-PraItem -Context $context -Status Warn -Text 'The default expectation is Provisioned; to check a rollback, give -Expect Deprovisioned.' } + } + } + if (-not $fromRecover) { + $context.Source = Import-PraBackup $context $batchFile + $context.BatchId = Get-PraShortId ([string]$context.Source.Data.BatchId) + if (-not $context.Source.Legacy) { $proofPath = Join-Path (Split-Path $context.Source.Path -Parent) ('State-' + $context.Source.Data.BatchId + '.json') } + } } if (-not (Test-PraOrdinalEqual $context.Source.Data.Operation 'Convert')) { throw 'The source of a cloud phase must be the original Convert batch.' } $context.SourceBackupHash = $context.Source.Hash @@ -1187,25 +1908,49 @@ try { # The journal folder is created after the operator's confirmation (below), never before it. $needCloudJournal = $true } + if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Convert')) { + Assert-PraBatchNotRolledBack -ObjectGuid @($(if ($null -ne $context.Proof) { $context.Proof.Data.Records | ForEach-Object { [string]$_.ObjectGuid } } else { $records | ForEach-Object { [string]$_.ObjectGuid } })) + } + $script:SourcePartial = ((Test-PraOrdinalIgnoreCaseEqual $Action 'Recover') -and $null -ne $context.Proof -and $null -ne (Get-PraPartialSourceProof)) + if (($null -ne $context.Proof -and (Test-PraOrdinalIgnoreCaseEqual $Action 'Convert') -and $context.Proof.Partial) -or $script:SourcePartial) { $script:Touched = Get-PraBatchTouchedSet } + $verifiedIndex = if ($null -ne $context.Proof) { Get-PraRecordIndex $context.Proof.Data.Records } else { $null } + $plannedIndex = if ($null -ne $context.Proof) { Get-PraRecordIndex $context.Proof.Receipt.Data.Records } else { $null } foreach ($record in $records) { $row = New-PraRow $context $record $originalLicensing = Get-PraValue $record 'Licensing' $null $row.PreserveLicense = ((Test-PraOrdinalIgnoreCaseEqual $cloudAction 'Recover')) -and [bool](Get-PraValue $originalLicensing 'Enabled' $false) -and [bool](Get-PraValue $originalLicensing 'WasMember' $false) - $row.PreserveCloudMailbox = ((Test-PraOrdinalIgnoreCaseEqual $cloudAction 'Recover')) -and $row.IsShared -and $context.KeepCloudShared + $row.PreserveCloudMailbox = Test-PraCloudMailboxKept -IsShared ([bool]$row.IsShared) -Operation $cloudAction -KeepCloudShared ([bool]$context.KeepCloudShared) $holders = Get-PraValue $record 'SharedPermissions' $null $row.SharedFullAccess = Get-PraValue $holders 'FullAccess' @(); $row.SharedSendAs = Get-PraValue $holders 'SendAs' @(); $row.SharedSendOnBehalf = Get-PraValue $holders 'SendOnBehalf' @() if ($null -ne $context.Proof) { - $verified = @($context.Proof.Data.Records | Where-Object { Test-PraOrdinalIgnoreCaseEqual $_.ObjectGuid $record.ObjectGuid }) - if ($verified.Count -ne 1) { throw "Object not verified by the AD phase of this batch: $($record.SamAccountName)" } - $row.ADVerified = $true; $row.DeproPending = (Test-PraOrdinalEqual $verified[0].Operation 'Deprovision'); $row.BackupPath = $context.Proof.Receipt.Path - $provenPlan = @($context.Proof.Receipt.Data.Records | Where-Object { Test-PraOrdinalIgnoreCaseEqual $_.ObjectGuid $record.ObjectGuid })[0] + $verifiedRecord = Find-PraRecord $verifiedIndex ([string]$record.ObjectGuid) + $verifiedCount = if ($null -eq $verifiedRecord) { 0 } elseif ($verifiedIndex.Duplicates.Contains([string]$record.ObjectGuid)) { 2 } else { 1 } + if ($verifiedCount -eq 0 -and ($context.Proof.Partial -or $script:SourcePartial)) { + # Partial batch: this object was not converted by it (or may be partly changed); the cloud part leaves it out. + $row.BackupPath = $context.Proof.Receipt.Path + Set-PraUnprovenRow -Row $row -Record $record -Reason 'not converted by this batch (it stopped at its first error before this object)' + $row.CloudStatus = 'Skipped' + continue + } + if ($verifiedCount -ne 1) { throw "Object not verified by the AD phase of this batch: $($record.SamAccountName)" } + $row.ADVerified = $true; $row.DeproPending = (Test-PraOrdinalEqual $verifiedRecord.Operation 'Deprovision'); $row.BackupPath = $context.Proof.Receipt.Path + $provenPlan = Find-PraRecord $plannedIndex ([string]$record.ObjectGuid) $row.PreserveCloudMailbox = [bool]$provenPlan.PreserveCloudMailbox; $row.PreserveLicense = [bool]$provenPlan.PreserveLicense } $context.Rows.Add($row) } $context.PhaseFolders = @(@(Split-Path $context.Source.Path -Parent) + $(if ($proofPath) { @(Split-Path $proofPath -Parent) } else { @() })) - Send-PraPlanCount $context.Rows.Count - Write-PraItem -Context $context -Status Ok -Text ("Batch {0}: {1} object(s){2}" -f $context.BatchId, $records.Count, $(if ($null -ne $context.Proof) { ', AD proof verified' } else { '' })) + # The cloud phase of a Convert keeps what it did in the batch folder, so that the console can tell a finished batch from one that is still to do. + if ($context.AllowMutation -and (Test-PraOrdinalIgnoreCaseEqual $Action 'Convert') -and (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Cloud')) { $context.PhaseWriteFolder = Split-Path $context.Source.Path -Parent } + $convertedCount = $context.Rows.Count - $script:NotConverted.Count + Send-PraPlanCount $convertedCount + Write-PraItem -Context $context -Status Ok -Text ("Batch {0}: {1} object(s){2}" -f $context.BatchId, $convertedCount, $(if ($null -ne $context.Proof) { ', AD proof verified' } else { '' })) + if ($script:NotConverted.Count -and (Test-PraOrdinalIgnoreCaseEqual $Action 'Convert')) { + $script:PartialContinuation = New-PraPartialContinuation -Side 'Cloud' -Verified $convertedCount + $leftOut = $script:NotConverted.Count - $script:MayBeChanged.Count + if ($leftOut) { Write-PraItem -Context $context -Status Warn -Text ('{0} object(s) of this batch were not converted by it (it stopped at its first error): they are left out of this run, see the next steps.' -f $leftOut) } + if ($script:MayBeChanged.Count) { Write-PraItem -Context $context -Status Warn -Text ('{0} object(s) may be partly changed (the batch stopped on them after a write was started): {1}. They are left out of this run, see the next steps.' -f $script:MayBeChanged.Count, (@($script:PartialContinuation.MayBeChanged) -join ', ')) } + } } $runCloud = $true } @@ -1213,7 +1958,8 @@ try { # --------------------------------------------------------------------------------------------- # Exchange Online part (after the AD part in phase Both, or alone in phase Cloud / Check). # --------------------------------------------------------------------------------------------- - if ($runCloud -and $context.Rows.Count -gt 0) { + $cloudRows = @($context.Rows | Where-Object { -not $script:NotConverted.Contains([string]$_.ObjectGuid) }) + if ($runCloud -and $cloudRows.Count -gt 0) { if ($context.Issues.Count) { throw 'Cloud part not started: the AD part has errors.' } $cloudTitle = switch ($cloudAction) { 'Recover' { 'Exchange Online: deprovisioning checks' } default { 'Exchange Online: mailboxes, licences and permissions' } } if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Check')) { $cloudTitle = 'Exchange Online checks' } @@ -1221,30 +1967,60 @@ try { # A preview of the cloud phase looks once: it never waits for the cloud. if (-not $context.AllowMutation -and (-not (Test-PraOrdinalIgnoreCaseEqual $Action 'Check'))) { $context.Once = $true } if ($context.AllowMutation -and (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Cloud') -and (Test-PraOrdinalIgnoreCaseEqual $Action 'Convert')) { - $grants = 0; foreach ($row in $context.Rows) { $grants += @($row.SharedFullAccess).Count + @($row.SharedSendAs).Count + @($row.SharedSendOnBehalf).Count } - Confirm-PraApply ("Complete {0} object(s) in Exchange Online (wait for the mailboxes, grant up to {1} shared mailbox permission(s))?" -f $context.Rows.Count, $grants) + $grants = 0; foreach ($row in $cloudRows) { $grants += @($row.SharedFullAccess).Count + @($row.SharedSendAs).Count + @($row.SharedSendOnBehalf).Count } + Confirm-PraApply ("Complete {0} object(s) in Exchange Online (wait for the mailboxes, grant up to {1} shared mailbox permission(s))?" -f $cloudRows.Count, $grants) } elseif ($context.AllowMutation -and (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Cloud') -and (Test-PraOrdinalIgnoreCaseEqual $Action 'Recover')) { - Confirm-PraApply ("Check the deprovisioning of {0} object(s) in Exchange Online, then package any final shared mailbox and tag restoration for the AD server?" -f $context.Rows.Count) + Confirm-PraApply ("Check the deprovisioning of {0} object(s) in Exchange Online, then package any final shared mailbox and tag restoration for the AD server?" -f $cloudRows.Count) } if ($needCloudJournal) { Initialize-PraCloudJournal } Initialize-PraCloudAuthority + if ((Test-PraOrdinalIgnoreCaseEqual $cloudAction 'Convert')) { Initialize-PraGrantSetting } Import-Module (Join-Path $PSScriptRoot 'module\PRA.Cloud.psm1') -Force -ErrorAction Stop - if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Check') -and (Test-PraOrdinalIgnoreCaseEqual $Expect 'Retained')) { Invoke-PraRetentionCheck -Context $context -Rows $context.Rows.ToArray() } - else { Invoke-PraCloudPhase -Context $context -Rows $context.Rows.ToArray() -Act $cloudAction } + if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Check') -and (Test-PraOrdinalIgnoreCaseEqual $Expect 'Retained')) { Invoke-PraRetentionCheck -Context $context -Rows $cloudRows; Save-PraRetentionProof -Rows $cloudRows } + else { Invoke-PraCloudPhase -Context $context -Rows $cloudRows -Act $cloudAction } + # Each grant checks the backup cheaply; a Convert that sent at least one (phase Cloud or Both) ends its grant work with one complete check. + if ($context.AllowMutation -and (Test-PraOrdinalIn $effectivePhase @('Cloud','Both') -IgnoreCase) -and (Test-PraOrdinalIgnoreCaseEqual $Action 'Convert') -and [int](Get-PraValue $context 'GrantsSent' 0) -gt 0) { + try { + Assert-PraReceipt -Context $context -Receipt $context.Source -Full + Write-PraItem -Context $context -Status Ok -Icon Backup -Text ('Backup of the batch checked in full after {0} permission grant(s)' -f [int]$context.GrantsSent) + } + catch { + $context.NextSteps = @('The backup of this batch changed while the shared mailbox permissions were granted. Check the Backups folder of this server (nobody should write there during a run), then run the same command again, it reads the permissions first and grants only what is missing:', + (Get-PraCommandLine -ActionName $Action -PhaseName 'Cloud' -BatchId $(if ($script:PackageArgument) { $script:PackageArgument } elseif ($Batch) { $Batch } else { $context.BatchId }) -KeepFilters)) + $context.NextOnFailure = $true + throw ('The final check of the backup failed after {0} grant(s): {1}' -f [int]$context.GrantsSent, $_.Exception.Message) + } + } $cloudErrors = @($context.Rows | Where-Object { Test-PraOrdinalEqual $_.CloudStatus 'Error' }) $runErrors = @($cloudErrors | Where-Object { [bool](Get-PraValue $_ 'RunError' $false) }).Count $notExpected = $cloudErrors.Count - $runErrors if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Check') -and $notExpected -and -not $runErrors -and -not $context.CloudConnectFailed) { Write-PraItem -Context $context -Status Fail -Text ('Check finished: {0} object(s) not in the expected state. Nothing was changed.' -f $notExpected) $context.CheckFinished = $true - $context.NextSteps = @('If the Entra Connect sync has not run since the Active Directory changes, run it first (Start-ADSyncSyncCycle -PolicyType Delta on the Entra Connect server, or wait for the next automatic cycle, about 30 minutes), then run the Check again:', - (Get-PraCommandLine -ActionName 'Check' -ModeName 'Preview' -BatchId $(if ($script:PreviewPackage) { $script:PreviewPackage } else { $Batch }) -KeepFilters)) + $rerunCheck = Get-PraCommandLine -ActionName 'Check' -ModeName 'Preview' -BatchId $(if ($script:PreviewPackage) { $script:PreviewPackage } else { $Batch }) -KeepFilters + if (Test-PraOrdinalIgnoreCaseEqual $Expect 'Retained') { + $checkedGuid = [string](Get-PraValue $context 'RetentionPolicyGuid' '') + $policyLabel = if ($checkedGuid) { ' (' + $checkedGuid + ')' } else { '' } + $policyName = [string]$context.Config.Retention.PolicyName + $detailCommand = if ($checkedGuid) { 'Connect-IPPSSession; Get-RetentionCompliancePolicy -Identity {0} -DistributionDetail | Format-List Name,Guid,Enabled,Mode,DistributionStatus,*Location*' -f (ConvertTo-PraLiteral $checkedGuid) } + elseif ($policyName) { 'Connect-IPPSSession; Get-RetentionCompliancePolicy -Identity {0} -DistributionDetail | Format-List Name,Guid,Enabled,Mode,DistributionStatus,*Location*' -f (ConvertTo-PraLiteral $policyName) } + else { 'Connect-IPPSSession; Get-RetentionCompliancePolicy | Format-Table Name,Guid' } + $keepProof = @(Get-PraList $context 'NextSteps') + $context.NextSteps = @(('The retention policy{0} does not hold, or could not be checked for, {1} mailbox(es) of this batch (named above). Look at what the policy covers: the mailbox must be in its scope and not excluded, and an adaptive scope can take several days to catch up. Read the policy with:' -f $policyLabel, $notExpected), + $detailCommand, 'Make the policy hold those mailboxes, then run the Check again (it writes a new retention proof):', $rerunCheck) + $keepProof + } + else { + $context.NextSteps = @('If the Entra Connect sync has not run since the Active Directory changes, run it first (Start-ADSyncSyncCycle -PolicyType Delta on the Entra Connect server, or wait for the next automatic cycle, about 30 minutes), then run the Check again:', $rerunCheck) + } $context.NextOnFailure = $true } elseif ($context.Issues.Count -or $cloudErrors.Count) { $isCheck = (Test-PraOrdinalIgnoreCaseEqual $Action 'Check') - $network = [bool](Get-PraValue $context 'NetworkFailure' $false) + $throttled = [bool](Get-PraValue $context 'CloudThrottled' $false) + $network = [bool](Get-PraValue $context 'NetworkFailure' $false) -or $throttled + $unanswered = if ($throttled) { 'Microsoft 365 limited the requests of this run' } else { 'Microsoft 365 did not answer from this machine' } + $whenAgain = if ($throttled) { 'in a few minutes' } else { 'when the connection works' } # The stop names the first object whose check failed. if (-not [int](Get-PraValue $context 'CloudNotReached' 0) -and -not (Test-PraOrdinalIn ([string]$context.CurrentOperation) @('Connect-MgGraph', 'Connect-ExchangeOnline'))) { $failedIssues = @($context.Issues.ToArray() | Where-Object { Test-PraOrdinalEqual ([string](Get-PraValue $_ 'Source' '')) 'Cloud' }) @@ -1253,12 +2029,12 @@ try { $context.CurrentIdentity = [string](Get-PraValue $failedIssues[0] 'Identity' '') } } - $lead = if ($network) { 'Microsoft 365 did not answer' } elseif ($isCheck) { 'The Exchange Online check could not be done' } else { 'Exchange Online check failed' } + $lead = if ($throttled) { 'Microsoft 365 limited the requests of this run' } elseif ($network) { 'Microsoft 365 did not answer' } elseif ($isCheck) { 'The Exchange Online check could not be done' } else { 'Exchange Online check failed' } if (-not $context.AllowMutation) { $again = if ($isCheck) { 'Check' } else { 'Preview' } $stop = '{0}. Nothing was changed. Run the {1} again.' -f $lead, $again $rerun = Get-PraCommandLine -ActionName $Action -PhaseName $(if ($isCheck) { '' } else { $effectivePhase }) -ModeName 'Preview' -BatchId $(if ($script:PreviewPackage) { $script:PreviewPackage } else { $Batch }) -KeepFilters - $first = if ($network) { 'Microsoft 365 did not answer from this machine. Nothing was changed: run the {0} again when the connection works:' -f $again } else { 'Nothing was changed. Fix the problem named above, then run the {0} again:' -f $again } + $first = if ($network) { '{0}. Nothing was changed: run the {1} again {2}:' -f $unanswered, $again, $whenAgain } else { 'Nothing was changed. Fix the problem named above, then run the {0} again:' -f $again } $context.NextSteps = @($first, $rerun) $context.NextOnFailure = $true throw $stop @@ -1267,7 +2043,7 @@ try { # The command is given as the operator typed it: the package path or the batch ID. $typedBatch = if ($script:PackageArgument) { $script:PackageArgument } elseif ($Batch) { $Batch } else { $context.BatchId } if ($network -and (Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Cloud')) { - $context.NextSteps = @('Microsoft 365 did not answer from this machine. What this run already did is kept: run the same command again when the connection works:', (Get-PraCommandLine -ActionName $Action -PhaseName 'Cloud' -BatchId $typedBatch -KeepFilters)) + $context.NextSteps = @(('{0}. What this run already did is kept: run the same command again {1}:' -f $unanswered, $whenAgain), (Get-PraCommandLine -ActionName $Action -PhaseName 'Cloud' -BatchId $typedBatch -KeepFilters)) $context.NextOnFailure = $true } elseif ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Cloud')) { @@ -1286,7 +2062,7 @@ try { elseif ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Both') -and $context.BatchId -and $null -ne $context.Proof) { # The Active Directory part of the batch is written and verified (Convert or Recover): only the Exchange Online part is left, and the batch is continued by its ID. $bothContinues = $true - $bothFirst = if ($network) { 'Microsoft 365 did not answer from this machine. What this run already did is kept (Active Directory is changed and verified): run the Exchange Online part when the connection works:' } else { 'What this run already did is kept (Active Directory is changed and verified). Fix the problem named above, then run the Exchange Online part:' } + $bothFirst = if ($network) { '{0}. What this run already did is kept (Active Directory is changed and verified): run the Exchange Online part {1}:' -f $unanswered, $whenAgain } else { 'What this run already did is kept (Active Directory is changed and verified). Fix the problem named above, then run the Exchange Online part:' } $context.NextSteps = @($bothFirst, (Get-PraCommandLine -ActionName $Action -PhaseName 'Cloud' -BatchId $context.BatchId)) $context.NextOnFailure = $true } @@ -1297,11 +2073,13 @@ try { if ((Test-PraOrdinalIgnoreCaseEqual $Action 'Recover')) { Write-PraStep -Context $context -Title 'Final restore of shared mailboxes and tags' -Icon Write if ($context.AllowMutation) { - $tagged = @($context.Rows | Where-Object { [bool](Get-PraValue (Get-PraValue $_.BackupRec 'Retention' $null) 'Enabled' $false) }) + $tagged = @($cloudRows | Where-Object { [bool](Get-PraValue (Get-PraValue $_.BackupRec 'Retention' $null) 'Enabled' $false) }) foreach ($row in $tagged | Where-Object PreserveCloudMailbox) { $row.FinalStatus = 'Pending'; $row.Detail += ' | Cloud mailbox kept on purpose: the retention tag stays.' } - $followup = @($context.Rows | Where-Object { -not $_.PreserveCloudMailbox -and ($_.DeproPending -or $tagged.Contains($_)) }) + $taggedSet = New-Object 'Collections.Generic.HashSet[object]' ([Collections.Generic.ReferenceEqualityComparer]::Instance) + foreach ($taggedRow in $tagged) { [void]$taggedSet.Add($taggedRow) } + $followup = @($cloudRows | Where-Object { -not $_.PreserveCloudMailbox -and ($_.DeproPending -or $taggedSet.Contains($_)) }) foreach ($row in $followup) { if (-not (Test-PraOrdinalEqual $row.CloudStatus 'Success') -or $row.DeprovisionConfirmed -ne $true -or $row.ADVerified -ne $true) { throw 'Cloud deprovisioning or AD proof not confirmed: restore and tag clean-up blocked.' } } if (-not $followup.Count) { Write-PraItem -Context $context -Status Skip -Text 'Nothing left to restore.' } elseif ((Test-PraOrdinalIgnoreCaseEqual $effectivePhase 'Cloud') -or $defer -or -not @(Get-Module -ListAvailable ActiveDirectory).Count) { @@ -1379,6 +2157,10 @@ try { $checkCommand = Get-PraCommandLine -ActionName 'Check' -ModeName 'Preview' -BatchId $(if ($script:PreviewPackage) { $script:PreviewPackage } else { $context.BatchId }) -KeepFilters $context.NextSteps = @(@(Get-PraList $context 'NextSteps') + ('X500 missing in Exchange Online for {0} object(s) (replies to old messages can bounce): run an Entra Connect synchronisation, then check again: {1}' -f $x500Missing.Count, $checkCommand)) } + + # The objects of a partial batch that this run leaves out: how to convert them, or how to undo the batch. + if ($null -ne $script:PartialContinuation) { $context.NextSteps = @(Get-PraList $context 'NextSteps') + @(Get-PraPartialRestStep $script:PartialContinuation) } + $context.RunReachedEnd = $true } catch { $failure = $_; $failureOperation = $context.CurrentOperation @@ -1431,6 +2213,16 @@ catch { } } finally { + # A run that ends without reaching the end of the main block and without an error (Ctrl+C, a closed window, a stop of the host) is never a success. + $interrupted = $false + if (-not [bool](Get-PraValue $context 'RunReachedEnd' $false) -and [int]$context.ExitCode -ne 1) { + $interrupted = $true + try { + $where = "Stopped at step '{0}' (operation {1}{2}): the run was interrupted before it finished (Ctrl+C, a closed window or a stop of the host)." -f $context.CurrentPhase, $context.CurrentOperation, $(if ($context.CurrentIdentity) { ', object ' + $context.CurrentIdentity } else { '' }) + Write-PraLog -Context $context -Message $where -Level Error + } catch { $null = $_ } + $context.ExitCode = 1 + } Initialize-PraPermissionCache -Context $context if ([string](Get-PraValue $context 'PreviewStaging' '')) { try { [IO.Directory]::Delete($context.PreviewStaging, $true) } catch { try { Write-PraLog -Context $context -Message ('The temporary Preview folder could not be deleted: {0}' -f $_.Exception.Message) -Level Detail } catch { $null = $_ } } @@ -1440,21 +2232,23 @@ finally { catch { Write-PraLog -Context $context -Message ('The data for the global report could not be saved ({0}).' -f $_.Exception.Message) -Level Detail } } if (Get-Command Close-PraCloudSession -ErrorAction SilentlyContinue) { - try { Close-PraCloudSession -Context $context } catch { $context.Issues.Add([pscustomobject]@{ Message = "Cloud sign-out: $($_.Exception.Message)"; Source = 'Cloud' }) } + try { Close-PraCloudSession -Context $context } catch { Write-PraItem -Context $context -Status Warn -Text ('The sign-out of Microsoft 365 failed ({0}). What this run did is not affected. If a session is still open, close it: Disconnect-ExchangeOnline -Confirm:$false; Disconnect-MgGraph' -f ([string]$_.Exception.Message -replace '\s+', ' ')) } } # What a failed run proposes when no step set a more specific next step. try { $context.FallbackNext = @(Get-PraFallbackNext) } catch { $context.FallbackNext = @('Fix the problem named above, then run the same command again with the same options.') } $result = Complete-PraRun -Context $context + # A run whose pipeline was stopped gives its exit code to the process only through the host. + if ($interrupted -and (Test-PraOwnEntryProcess)) { try { $Host.SetShouldExit([int]$result.ExitCode) } catch { $null = $_ } } if ($PassThru) { $result } exit $result.ExitCode } # SIG # Begin signature block -# MIImKgYJKoZIhvcNAQcCoIImGzCCJhcCAQExDzANBglghkgBZQMEAgEFADB5Bgor +# MIImKwYJKoZIhvcNAQcCoIImHDCCJhgCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDBldMnzAsM7r0A -# Gou1kqH4Jk/bBL1tsc1AXt+MCK0OM6CCDW8wggZyMIIEWqADAgECAghkM1HTxzif +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCA0s4hin6IYQ1tx +# 4wsCyP33sM4Dwn5dud5YIa3CBhdMTKCCDW8wggZyMIIEWqADAgECAghkM1HTxzif # CDANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx # EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8G # A1UEAwwoU1NMLmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTAe @@ -1526,28 +2320,28 @@ finally { # ULeH38N0Vr83psiJVuBSxQyt5nRVrpYz7FACq5gtXELkyViq/rGOlJKaRrgQ6WWq # eoIXqKhV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eb820lajgt3m97e5M+dpj4JWbJV3J2plY3meQ== # SIG # End signature block diff --git a/package/PackageIntegrity.psd1 b/package/PackageIntegrity.psd1 index e057791..5f4fb46 100644 --- a/package/PackageIntegrity.psd1 +++ b/package/PackageIntegrity.psd1 @@ -1,83 +1,84 @@ -# PRA Remote Mailbox 3.1.4 - authenticated package integrity manifest +# PRA Remote Mailbox 3.2.0 - authenticated package integrity manifest # Generated only after the final stable-file signatures and timestamps. @{ SchemaVersion = 1 Algorithm = 'SHA256' SignerThumbprint = '0F28E442889F17B5F4D251E8F96E7CC6E2C9C6D6' Files = @( - @{ Path = 'Invoke-PraRemoteMailbox.ps1'; Sha256 = 'E7D0DE3CFDCD316609C05297DE50F31A94711179D94B2F9955B62040D4113F0E' } - @{ Path = 'PraRemoteMailbox.psd1'; Sha256 = 'F88291C4FFD0392401BA4615B72D27834FB4F608A7A284878C8F81EC80CCB401' } - @{ Path = 'PraRemoteMailbox.psm1'; Sha256 = '19A4AEDF4D66676C56E9471A79257052631E4F21A0C00DA9942ADC1F77146CA1' } - @{ Path = 'module\PRA.Common.psm1'; Sha256 = '89812D5B5B948CB5ADFA8F14887E04107DC8481C83A1FA072CBD9F281B96ED58' } - @{ Path = 'module\PRA.Directory.psm1'; Sha256 = 'C0EA8F5C2470D5538F4393AF37F3C7BCA8AFB73DF86FFC706BE803740A100D3B' } - @{ Path = 'module\PRA.Backup.psm1'; Sha256 = 'EFC1D82B90BDFD07E43B2D2FFE89D6A1A0FAAB48A13B25C42F4DFC5EE6C36593' } - @{ Path = 'module\PRA.Cloud.psm1'; Sha256 = '25838C25C3AF617344595A2F1BDC2BF1B13D786E67871FF2DC7C0AE54BA072C4' } - @{ Path = 'module\PRA.Gui.psm1'; Sha256 = '0CB4B57111AC022888A744D5197BB28BD878D18C0988CC3C2E73C685D2E2F556' } - @{ Path = 'module\PRA.Gui.Directory.ps1'; Sha256 = '5D108F4B4D3FE700B6F6192C3AD9930413A438282BF2558D1D545301E9780E28' } - @{ Path = 'module\Test-PackageIntegrity.ps1'; Sha256 = '98ECA0021AFB8A53243712992E61A3A6F9B2EAF96531EA7EDDC1A7FA8F10AE21' } - @{ Path = 'module\PRA.Gui.xaml'; Sha256 = '2DBCB014EC62F47A28DD3DAFB03C4ED7B646648261EA99B9488CFD712BA02F48' } - @{ Path = 'templates\Report.template.html'; Sha256 = 'B6FE7B407959F7C088F72D30238D78C62774FD837EF52126A45F350B70E57C4A' } + @{ Path = 'Invoke-PraRemoteMailbox.ps1'; Sha256 = '0B63A8E2FBD565DFFECA2611C70955345F209F65D1022B85CFC262CC3042B03A' } + @{ Path = 'PraRemoteMailbox.psd1'; Sha256 = '0819F364EEECE7A761721CE97AA6FAD3AAE7031784E3384E00058B6396F78F52' } + @{ Path = 'PraRemoteMailbox.psm1'; Sha256 = 'BB578BF571D84485B561017CDF7169982E0C71EEFBBAFD5EEA1913380FF2588B' } + @{ Path = 'module\PRA.Common.psm1'; Sha256 = '002D221191862C913D2837025275B42A19C343579D60F363A9F19E377B0EE4D4' } + @{ Path = 'module\PRA.Directory.psm1'; Sha256 = '1F6E0B07F3523C4DFE622CAAA89CA634FDCCF655916454B0984C521AA14B15A6' } + @{ Path = 'module\PRA.Backup.psm1'; Sha256 = '3F1D929E907248B7F3429CEF86429BE76D034133CB2090D5567A6C8DEEDEE0DE' } + @{ Path = 'module\PRA.Cloud.psm1'; Sha256 = '8ECB7C0F14193B2ECF49700C116D0CBA6FAB40427D1066A48993CE56119D1845' } + @{ Path = 'module\PRA.Gui.psm1'; Sha256 = '99C35BE8D3D405A52F508CF582120A5BE1623E8D99C856A98C48D0DAEF78A818' } + @{ Path = 'module\PRA.Gui.Directory.ps1'; Sha256 = '1E709980A4E56A8766E22DDF797A3AE8E865A05A8E267293CA351249730B999E' } + @{ Path = 'module\Test-PackageIntegrity.ps1'; Sha256 = '8661BDCD7B9A8E8053397A0B7D7B9CDC843CAF5A528B20A1B4CDEFA28084224D' } + @{ Path = 'module\PRA.Gui.xaml'; Sha256 = '926464F32E1AB1D31B5D312F329564F53FA95AA181B5DB7F17E38AA04AB66127' } + @{ Path = 'templates\Report.template.html'; Sha256 = 'A4E372FAAEBD6E6CA8434CF5FD3190EF2878CE87D5CE35DB56780C5000657476' } + @{ Path = 'templates\GlobalReport.template.html'; Sha256 = '94A3AA61C9B079D4A9F7863CE34E4C39E96F1A81492C8BBB380063EBD7D71580' } @{ Path = 'config\Targets.sample.csv'; Sha256 = '564C746AFDE5A5EADEBFD4449A7BB372B4D63E8B7C8352ACF825458650A458EF' } @{ Path = 'config\SharedPermissions.sample.csv'; Sha256 = '7838261190B01E705505EAE8C1664FCFD9143E4E3F39D3E0968A02A0B7951B5F' } - @{ Path = 'README.md'; Sha256 = '70257AEF76C36E1646F4F5FC7D6FE67B043F4677103A244B8343A8A250E46DE5' } + @{ Path = 'README.md'; Sha256 = '838D8987DB5867FF1A45709C1361CA542DE1E923500783BB1098472FE9423C5C' } @{ Path = 'LICENSE'; Sha256 = 'A91A28EED601C15D06E439F83666F0EBE1AA7897DE37D350108147C7804FD94B' } - @{ Path = 'docs\PraRemoteMailbox-Guide.html'; Sha256 = 'E26C2B78CDC8B797991C18139AA30B4BEA5544F9FEC02B70E552E837811AA9B3' } - @{ Path = 'docs\PraRemoteMailbox-Guide.md'; Sha256 = '53E3446109800FF0DA8262022546BE61AD6D9AB58A2E9E29A2B3AFE4457A202C' } - @{ Path = 'docs\PraRemoteMailbox-UserGuide.html'; Sha256 = 'F1EE6585CCD08D3E8EEA71FCA076F6DD9270CE751E6F4428A070C458D85B2147' } - @{ Path = 'docs\PraRemoteMailbox-UserGuide.md'; Sha256 = 'C392B433A698BAC2280C7C5E1BF004B12A29858BF3ACA7BF8960BC57E027116B' } - @{ Path = 'docs\images\console-next-cloud-light.png'; Sha256 = '301F870492C71F628813CE538F705E4543465B953B2DEC3E049AC7BE76B5B246' } - @{ Path = 'docs\images\console-next-finalize-light.png'; Sha256 = '4EBF7C46ECB4C5D4650A6C6631D90854111F4973F1C46456C7EF8215270065B5' } - @{ Path = 'docs\images\console-next-global-light.png'; Sha256 = 'E8F049B1301DB83ABD2E13FC6DFD960BBF6D1BB39BA26EF38CF7AC11E4C0AE01' } - @{ Path = 'docs\images\console-next-light.png'; Sha256 = '70237878A8E706FD43CCA187DE07C68C2CEB027DE296801B672F42B25F2DE1EC' } - @{ Path = 'docs\images\console-next-package-light.png'; Sha256 = '3ABB8F54ED1D57BDE21BDF17AA0E523AB84E6990870958CB86943CCFB8962003' } - @{ Path = 'docs\images\console-next-rollback-cloud-light.png'; Sha256 = '83F1F0126BEC124CC55CB0F1C1A69845944036B578E609FDDE5813D9ADBAAC1A' } - @{ Path = 'docs\images\console-next-rollback-light.png'; Sha256 = '815ACFC01E5844F01573E7466FA03F612B6110C61921C6379BFCA63180F202DB' } - @{ Path = 'docs\images\console-next-rollback-package-light.png'; Sha256 = 'F7165F398925250806091F959179088B305F5528294A9D22FF944FED58F7C7FD' } - @{ Path = 'docs\images\console-next-syncfailed-light.png'; Sha256 = '955C6E47A65D8491DF35B140EE5F3D1F83DC43ED629E15B9389BAB835BF9C32E' } - @{ Path = 'docs\images\console-run-cloud-light.png'; Sha256 = '912882330FEC8308D3A31B5DCAFAC13772749472A79E13D555B4149B63AA8BA5' } - @{ Path = 'docs\images\console-run-early-light.png'; Sha256 = '80DEFD52007ECD0EC53D56C1AE172588E39119F44BCAD1EB1C22A55240091E90' } - @{ Path = 'docs\images\console-run-finalize-light.png'; Sha256 = 'A4F63D33751E927BB40B5F9E8774F6DD3732E7B1485B060B45624533E7CA0A34' } - @{ Path = 'docs\images\console-run-finished-dark.png'; Sha256 = '3F9D5881478239BB8C787F2BB5DF9478EDE9FF5E606C7D55525F38655689F3CA' } - @{ Path = 'docs\images\console-run-finished-light.png'; Sha256 = '3D77A148655C79CD929E3CD08DCAA3AFA6EABED221FE751950FD852DC105FCCD' } - @{ Path = 'docs\images\console-run-grant-light.png'; Sha256 = '976C9314782506F7063F6D618C498233E4E40E9C7F535B45951B80AD3D7AB2C4' } - @{ Path = 'docs\images\console-run-package-light.png'; Sha256 = '734D87D9402E1F3E17AA21479D81972B9176971E032FFB99801808FACBE17A65' } - @{ Path = 'docs\images\console-run-rollback-cloud-light.png'; Sha256 = '0ABC61A5D09DF42795CE82C3FCBE5D76A822DC06D5B7A09F034968C4910CF449' } - @{ Path = 'docs\images\console-run-rollback-light.png'; Sha256 = 'AECCAE36085135070A71E3282A939F85E1CC61C42AB673F428131AB24E97D240' } - @{ Path = 'docs\images\console-run-syncfailed-light.png'; Sha256 = 'B726CBEEC90E79B903176BC2974094C5489C7BFB575366B1D8207D709257F749' } - @{ Path = 'docs\images\console-run-waiting-light.png'; Sha256 = 'F46AAC98D1EDE706DBE686E34ABAE73146355161950166467BFFB067C559C17E' } - @{ Path = 'docs\images\console-settings-light.png'; Sha256 = '70056A639D0AD12CBAA4ABC5195CB1D005465E6C8EFFD69C166FB3B422ACA070' } - @{ Path = 'docs\images\console-setup-dark.png'; Sha256 = 'FFD720FA1C607441B5625488E401FEB30233EE678800E7789D6C201CBA516F91' } - @{ Path = 'docs\images\console-setup-light.png'; Sha256 = 'ECFEC30A4A017A1B6F5032AA6D175B9B086DFB9A61553E7E4B57523CB409C106' } + @{ Path = 'docs\PraRemoteMailbox-Guide.html'; Sha256 = '9EAC774A1C10693A9731E9E330B6345A7B88B38A8D30E488A5932947CC52F268' } + @{ Path = 'docs\PraRemoteMailbox-Guide.md'; Sha256 = '251A28E51CA473C18CCAA17A21DE8933BF852B80802AC5867CE10BE9C68ADFD1' } + @{ Path = 'docs\PraRemoteMailbox-UserGuide.html'; Sha256 = '4F917DC2AE84B9A885B820CEFEBAC622E547534C11BD8E538219A427F5FE8C07' } + @{ Path = 'docs\PraRemoteMailbox-UserGuide.md'; Sha256 = '9CBFF2A58D3755065E8FD2F0387421AFF091532D0E7871E61BC8CDCAD2245B27' } + @{ Path = 'docs\images\console-next-cloud-light.png'; Sha256 = '2B06B3077E5CF75B9B5CBEB1F857EF354FDD5B8CC0707913F764F7A26847A8A8' } + @{ Path = 'docs\images\console-next-finalize-light.png'; Sha256 = 'FE6A93F0C91666E10FED74CB351EE5DAC61E990E12945F472B16AABEC1D4094E' } + @{ Path = 'docs\images\console-next-global-light.png'; Sha256 = 'ED9B859FB462962DD7AD069C7A83CBE9742F668294EEE9F96D947B55DD4B3696' } + @{ Path = 'docs\images\console-next-light.png'; Sha256 = '39EDB212B53F2EC4AA4DFCD4CE52006AA64FF142CCE0C7DA51F81084BBC55EB3' } + @{ Path = 'docs\images\console-next-package-light.png'; Sha256 = '204B24BD6232306CA129F99820026C5BD5A415423F7FDE595DE0D33FBC492BE6' } + @{ Path = 'docs\images\console-next-rollback-cloud-light.png'; Sha256 = '4896914C2A4605DE9E1CE6E59CA3573289BD5E5B17436F69937F984C3A360B4C' } + @{ Path = 'docs\images\console-next-rollback-light.png'; Sha256 = 'A64E162489CEFB0B59B4E214A01FEC641EC7BB87F31C72AAA5DA31A09383BF3C' } + @{ Path = 'docs\images\console-next-rollback-package-light.png'; Sha256 = '6C03D32C2170609B8AFBFF5A12392FD3726DA0AC79DEC53935C9476709A6E890' } + @{ Path = 'docs\images\console-next-syncfailed-light.png'; Sha256 = '93B25C9CFA1CB5A231A45B91E1CB465980AAFA89C9D48FED278FA830C081BC6F' } + @{ Path = 'docs\images\console-run-cloud-light.png'; Sha256 = 'A0E5853FDBECC9F34AB1B95F8A0A90230D857AC063A4BD4D2FB27AC392D401B6' } + @{ Path = 'docs\images\console-run-early-light.png'; Sha256 = '821CB4E70C724DF56F9D07A1C83D6959556A37F26962D5C38B679474FF650769' } + @{ Path = 'docs\images\console-run-finalize-light.png'; Sha256 = 'AF496E0D22E6405499046A7799C951F53B245071B4B5014FECDCDEA71ADBB795' } + @{ Path = 'docs\images\console-run-finished-dark.png'; Sha256 = '97E77CDF5062CEED960E132C9A93543817F2309691AA5EF60419A756D7256051' } + @{ Path = 'docs\images\console-run-finished-light.png'; Sha256 = '7CF9F7277CB124D57530A9B19ACCB90D990470B336092B611ED5EE56A7076E88' } + @{ Path = 'docs\images\console-run-grant-light.png'; Sha256 = '66A3AF0D7C35C81DF0C3BFB2E5E648033A0D56BBF86E7B97875A2B764C0D7B35' } + @{ Path = 'docs\images\console-run-package-light.png'; Sha256 = '3A0C0F947AA6AD3C536A5A129D864E518B0DC0A1C363E1918805DD95375EDDF6' } + @{ Path = 'docs\images\console-run-rollback-cloud-light.png'; Sha256 = '956191ECE898D53980D9FE1181B182196A3A93FE7AD9A619E5998FF2EE3101E3' } + @{ Path = 'docs\images\console-run-rollback-light.png'; Sha256 = '321DA93B4F5A93903F4306A9FAFDF03986E65C4B7B10A78797A6D6C3F1227A04' } + @{ Path = 'docs\images\console-run-syncfailed-light.png'; Sha256 = 'B94A80EE8C014857F7468D3001DD1C1E3119FFA78145BD80115EB9B27C987272' } + @{ Path = 'docs\images\console-run-waiting-light.png'; Sha256 = 'B0882303A50DC17DEB4EC83D0E70FDE093A5585FA72AA66DA008618FE5DF88CD' } + @{ Path = 'docs\images\console-settings-light.png'; Sha256 = '7134526BDA90AA59C8D238362F4F6DD7EEC40C61D04F7F9F5C8B82EE0EADDAEC' } + @{ Path = 'docs\images\console-setup-dark.png'; Sha256 = 'F46A8DE9A5ED9C911F5EF8B7AE343A749427350570933DC467AD180092C4C9A8' } + @{ Path = 'docs\images\console-setup-light.png'; Sha256 = 'BE18893B4E178C42E1EF7EAF173AD94FD1DB970385CA138718F4834A685D4EA0' } @{ Path = 'docs\images\console-setup-lights-light.png'; Sha256 = '025A1A52F8B55C247B99107186D9CBA05765BFD70DD7365CB9A9615E95614219' } - @{ Path = 'docs\images\console-setup-next-light.png'; Sha256 = 'A53D8427A07FED77B72C7BF013D3EC1CE104B668DDBEEFC2F3D680E86B0A5697' } - @{ Path = 'docs\images\console-setup-red-light.png'; Sha256 = 'E06E0898E6F41AAF3175326F747D8F39D003DC731A21BC295D138AB62DE58D38' } + @{ Path = 'docs\images\console-setup-next-light.png'; Sha256 = '69664ED3C941C16A8E16A84D27CADE42C37C108ADCF1E77AD50FDFD1CD658468' } + @{ Path = 'docs\images\console-setup-red-light.png'; Sha256 = '4837EDB08A1E822216652A0C87F82EB6860D39730EB957EFB5EA9F008242EFE3' } @{ Path = 'docs\images\console-setup-red-lights-light.png'; Sha256 = '258F672EBE91826DAA7669F4A367D5936439E89B9FBEB14685B9CF66A81F87AE' } - @{ Path = 'docs\images\console-task-ad-light.png'; Sha256 = '7DBD4EB7B6DD6AB1FC306F873E3AB16C818E1E3C85DF4CFAB101D87A20C23642' } - @{ Path = 'docs\images\console-task-check-light.png'; Sha256 = 'EA9D3FC90E9376E6CD4DF6A293C5208DF8591FFB958683C7FF0572DC09717EFA' } - @{ Path = 'docs\images\console-task-continue-light.png'; Sha256 = '725027F95D96B6D07129ADB3814E272ABBD846B99A31C0D2F95178A494E9CF8C' } - @{ Path = 'docs\images\console-task-finalize-light.png'; Sha256 = '6BBD40DA52E9F4C9282774D83DCBF7ABC1C4CC5B11B2D5BFA35BDE01F96FD4FC' } - @{ Path = 'docs\images\console-task-finish-light.png'; Sha256 = '6BBB6AD09079ACCDBE06D74AB78DE8664A08FA00D3A19E080DB932CAFCEB6383' } - @{ Path = 'docs\images\console-task-group-light.png'; Sha256 = '80241D837B0DE7E786519DBAF9FB40C4B8C2C393FD2E1D318EA01DECAB877BFA' } - @{ Path = 'docs\images\console-task-identity-light.png'; Sha256 = '5BB9B887CD80D8B43EB9E812C065F761CB76BE936DE662FB1B3A34B479703341' } - @{ Path = 'docs\images\console-task-light.png'; Sha256 = '0D73DADF2E7C3CBA3BA3F5274F790CF195B093A5125EE9230154CDD569D7E0C5' } - @{ Path = 'docs\images\console-task-package-selected-light.png'; Sha256 = 'F58A7C40981E9F58DDF643BBD249F4697911443856CBA39B6EB40C503A34FDB4' } - @{ Path = 'docs\images\console-task-rollback-ad-light.png'; Sha256 = '0BF024FBC23863521AEB475DB9F582D6B5B879AD7F1206E2881CE4FCFE7B5348' } - @{ Path = 'docs\images\console-task-rollback-continue-light.png'; Sha256 = '4C7073C6E9DA7C2877D15FE579983045170211C8CFC1C4542545D917C114EE74' } - @{ Path = 'docs\images\console-task-rollback-light.png'; Sha256 = '9CA59634D1263CA493D1BE9E77BE19F5940995F3A3415F6FED932B3FEF39372E' } - @{ Path = 'docs\images\console-task-rollback-package-light.png'; Sha256 = '2BC89C31CD4F1E728E85EE5DA79CA5EC9DED7B1458B9F489F0BE318D66FE2D5C' } - @{ Path = 'docs\images\console-task-rollback-selected-light.png'; Sha256 = '3911047D46D49AE2543E80D0EEA24276D31447211621CAD289A5696AD91B8B0C' } - @{ Path = 'docs\images\console-task-scope-light.png'; Sha256 = 'D2DDA359E232D1B204280D9E2EB5EEB45867ECAAFAD4BEBFE20157BCBDDC0912' } - @{ Path = 'docs\images\console-verify-before-light.png'; Sha256 = '8623BCEEC2DD3DD458B7A769B6E641750014CA93EFB8E13B238EF740A7CA8B7F' } - @{ Path = 'docs\images\console-verify-check-light.png'; Sha256 = 'D95AAE29A45DDD8952A2DFAC12103BF6C5281B7808C19CBDCFCD5F931E7379DD' } - @{ Path = 'docs\images\console-verify-cloud-light.png'; Sha256 = '2CEC75716328AD4ED57875C76D6968027D75E16912E8F09A7BD7A81A790E2E28' } - @{ Path = 'docs\images\console-verify-finalize-light.png'; Sha256 = '12B895D43896B64D52D9C1C78AB9AAAB6470109A1539B655A77B9B672610893F' } - @{ Path = 'docs\images\console-verify-light.png'; Sha256 = '2CC03D2164D391189D9256B850BF6803CB9AA6E0945A830013F351511C65AA23' } - @{ Path = 'docs\images\console-verify-rollback-cloud-light.png'; Sha256 = 'A7298E9FF91485B104A6A58B99A69C59820E51042D52DC489295F5D522969FFE' } - @{ Path = 'docs\images\console-verify-rollback-light.png'; Sha256 = '6836FEF8D0176738477B1B6B5FAEFF5704E8AA393F63FDDF87F3E89CDE1D0D3B' } - @{ Path = 'docs\images\console-verify-scope-light.png'; Sha256 = 'B325EAB4A706296722EF939AE6CBF719B3791DCC7B623B3A06DFF1033EEA43BF' } + @{ Path = 'docs\images\console-task-ad-light.png'; Sha256 = '5B2612E0A324FB8ABF7E1247A87E491CF74B0DCFDB1073E7AC9A8509F23EBB65' } + @{ Path = 'docs\images\console-task-check-light.png'; Sha256 = '025B53B28A6652C242DE6938A31C376DC94C83CFE232A3330DC2A883B907E737' } + @{ Path = 'docs\images\console-task-continue-light.png'; Sha256 = 'FAE1C8112B3382E4D007231F04795695363256269C9803255B086867C771A43A' } + @{ Path = 'docs\images\console-task-finalize-light.png'; Sha256 = '3BAECA44F306A408ECEB492CA155FC24CCF204B5C9064FCD1590504DDD9ABE1C' } + @{ Path = 'docs\images\console-task-finish-light.png'; Sha256 = 'BBEF495B9B44E953B3E90F26456CD77FA63350A13366138A3FA226903DB086CA' } + @{ Path = 'docs\images\console-task-group-light.png'; Sha256 = '31AA83F1BEA6193831B12F83D369F64548F8DF3197ED8D5CA7F627DF1D720588' } + @{ Path = 'docs\images\console-task-identity-light.png'; Sha256 = 'E43BCA648FBF0AE1AF729097F7FEC98C73FA76B966496F5C431EFFE2CBC7D063' } + @{ Path = 'docs\images\console-task-light.png'; Sha256 = '73CB507EB570E968214EB6537E6B9293AAEB2A43364B0325FC245C6AD070739B' } + @{ Path = 'docs\images\console-task-package-selected-light.png'; Sha256 = '1C6D70FAEAD980DEC7E4A408D1D3E2F9A1F7A9B473174D5E43662C890D73CBCC' } + @{ Path = 'docs\images\console-task-rollback-ad-light.png'; Sha256 = 'CD654C08FAAD78C372DEA56EFAEA8C5FDC81D0BCEDD2D440DD92D52C0DB30ECF' } + @{ Path = 'docs\images\console-task-rollback-continue-light.png'; Sha256 = '24B38327F3B4BA3D5CEAC52F026A578B58BEAEEA12BB07B581D7803E86C57847' } + @{ Path = 'docs\images\console-task-rollback-light.png'; Sha256 = 'E581F62FF96DAF577975CA7457722DCBFE05398D08A4800B2B408D1CEB011001' } + @{ Path = 'docs\images\console-task-rollback-package-light.png'; Sha256 = '40706B99EEF4C8FEBD6B04DBB339EDA565D9BE5AA41D2F201174AF9D9497923D' } + @{ Path = 'docs\images\console-task-rollback-selected-light.png'; Sha256 = '130F8D7883788D53DD3EDFF20C5830454D53594FFB85C868DB6C04A1831E8651' } + @{ Path = 'docs\images\console-task-scope-light.png'; Sha256 = 'F840E55CDC869AA4132FCE201C29B52F6C321C200D4320229D9400AFAD327E1C' } + @{ Path = 'docs\images\console-verify-before-light.png'; Sha256 = 'C937EB331AC544FC4107515C5F024DF7B5C184A5BBADFD36197B8B087B789DDB' } + @{ Path = 'docs\images\console-verify-check-light.png'; Sha256 = '1C69C6EE740E59E0E3C97F1EF31F60911C7A2865829E2D5E9A6805FE0EA3E15C' } + @{ Path = 'docs\images\console-verify-cloud-light.png'; Sha256 = '4E5DA56FC99FA2C59F62A5C824C42677820CD6937462124945E013CF01B34BCC' } + @{ Path = 'docs\images\console-verify-finalize-light.png'; Sha256 = '5891F4AF28B788E1367B4526CB718C8F2AF1C7638F9375E87FEF412ED9FD528F' } + @{ Path = 'docs\images\console-verify-light.png'; Sha256 = '5CABC5B44E900EBA4252E0B75DF8F42DAE90ABFA414BBF6D4AE3266F247A4112' } + @{ Path = 'docs\images\console-verify-rollback-cloud-light.png'; Sha256 = '066DF9D4EA4BAEACA4B47F7755F3434336A3A33187384196E752A8C5905B90B8' } + @{ Path = 'docs\images\console-verify-rollback-light.png'; Sha256 = '310A150A9B502C8424ACF0C71B34BF00899EB65540AB420C15F8927B2FBFC446' } + @{ Path = 'docs\images\console-verify-scope-light.png'; Sha256 = '13CA68C255B191BF5FFB83E8CFD3DCA0A30D549880F8B16BF2AE0604C9F57178' } @{ Path = 'docs\images\guide-dictionary-light.png'; Sha256 = 'CCB62F52E60CBC27196C454A31892EE3AA68A88650040C397AEE01B69639E112' } - @{ Path = 'docs\images\readme-banner-dark.png'; Sha256 = '089974413C83190AE830ADD52E99220F59A438C769F8847FA223C196480F6CF0' } - @{ Path = 'docs\images\readme-banner-light.png'; Sha256 = '7693DB9B1661534B31C49385C0B4A4B83A1C642BC5B0C6A9F14798D4A76C4001' } + @{ Path = 'docs\images\readme-banner-dark.png'; Sha256 = '8D4664C6207B081D3032E8BEC0DB2068D76DDF8FC52D5514C6AA5D80207A73FF' } + @{ Path = 'docs\images\readme-banner-light.png'; Sha256 = '97102DCF7A143A6A17E508701CCD29FFC21665028C3BE694224AFBB5876D4A5B' } @{ Path = 'docs\images\readme-flows-dark.png'; Sha256 = '5506575A6FA0729673A8C4FB5C1852D39E449B49104706C563E752DAE21D2EA4' } @{ Path = 'docs\images\readme-flows-light.png'; Sha256 = '169597ED1DB78B467B727C762D2E5022CFC67C355FED405B529F49C9CCC7C081' } @{ Path = 'docs\images\readme-how-dark.png'; Sha256 = 'D294589619F38AE783DE83F64E84F27475367D17F1C1CEE4FDD08E80F5D7E807' } @@ -94,19 +95,19 @@ @{ Path = 'docs\images\readme-transfer-light.png'; Sha256 = '22D2935904AF42AB10928B1E2656E4024EB947E58C021ABFBE67871D54854328' } @{ Path = 'docs\images\readme-why-dark.png'; Sha256 = 'A22E81936573F37500D99D54040269F39EC0BDF99E997F350FE3BA68CFE5E997' } @{ Path = 'docs\images\readme-why-light.png'; Sha256 = '91C0E1F0AE64D464B08175F2D2CE91582023ABEA42B24049D49F231AE54A9097' } - @{ Path = 'docs\images\report-global-light.png'; Sha256 = '6D15E55A6A1C2805EB732F0AF99D8E527E783F5187BE4CF070071F494BC40498' } - @{ Path = 'docs\images\report-global-recover-light.png'; Sha256 = 'B17E6B7F06B438C2D22F43D0B1542341253AD2DA6586F2E51442ABD458BFD7E8' } - @{ Path = 'docs\images\report-phase-light.png'; Sha256 = '4F62AAFF87FC0C7E7DFF38032F8FDC4BBA6A6FC0373611A01C54AD8603D4CA93' } - @{ Path = 'docs\images\report-phase-warning-light.png'; Sha256 = 'DA0622931FC47CACC1388E378D569BB7D64B1FCE1279EDDD0F95ECCB9DEC41A1' } - @{ Path = 'CHANGELOG.md'; Sha256 = '4816EA350A4DD168D0D1016B25D0B023C4527253E418CAECD4C20E94152F590B' } + @{ Path = 'docs\images\report-global-light.png'; Sha256 = 'D250A104BA76955C6E0D67C6A702B6EEFE5D3C54AA3FBA8CB92B0386DD10B3D6' } + @{ Path = 'docs\images\report-global-recover-light.png'; Sha256 = 'ED9C07C1EC5CAFC1F5F71CFE91C1D42583123345537442EBA69FFCC3259A21F7' } + @{ Path = 'docs\images\report-phase-light.png'; Sha256 = '51BF6E54E5F5AB8DAD12DF7038064B6B3218608054470C115E0E51683EC7E30F' } + @{ Path = 'docs\images\report-phase-warning-light.png'; Sha256 = 'FDEF32D729A83D19AE7DBE4ECD51F9644B066E1688BC3622CF724F54C8B47796' } + @{ Path = 'CHANGELOG.md'; Sha256 = 'BC81DE2188F1BFDCDF42518BBB8DF72A5D767A43FBE0FFB2ADA9317F59025654' } ) } # SIG # Begin signature block -# MIImKgYJKoZIhvcNAQcCoIImGzCCJhcCAQExDzANBglghkgBZQMEAgEFADB5Bgor +# MIImKQYJKoZIhvcNAQcCoIImGjCCJhYCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCNlGC3/Y85IReP -# M9iu5gz7k0/zEyWyrZzRtrfbZvgwuqCCDW8wggZyMIIEWqADAgECAghkM1HTxzif +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCMndwpVH8bL2xe +# IoS8PBZoOc5BIJDATYb0hoFiwR5WMaCCDW8wggZyMIIEWqADAgECAghkM1HTxzif # CDANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx # EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8G # A1UEAwwoU1NMLmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTA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LJvXhDCAu0QuvIpkcCkIR +# zj0EAwIERjBEAiBD+tyWjxIONFXRC6OFCQzCF2sTwnOqAxZG0UWJr1yOsAIgTDaj +# IjaUqbYxjO1TD7mxHL8DG4yJ6Gn5hRDwI3aFp8g= # SIG # End signature block diff --git a/package/PraRemoteMailbox.psd1 b/package/PraRemoteMailbox.psd1 index 28ff287..9f78c5d 100644 --- a/package/PraRemoteMailbox.psd1 +++ b/package/PraRemoteMailbox.psd1 @@ -19,7 +19,7 @@ # @{ RootModule = 'PraRemoteMailbox.psm1' - ModuleVersion = '3.1.4' + ModuleVersion = '3.2.0' GUID = '1d97585b-d077-4d74-bf10-4e36d16308b6' Author = 'Nicolas Fabert' Description = 'PRA Remote Mailbox: disaster-recovery tool for an Exchange hybrid environment. Converts on-premises mailboxes to remote mailboxes and back (Active Directory and Exchange Online), with a backup before every write, a proof after it, a guided console and a transfer package between the Active Directory server and the cloud server.' @@ -33,11 +33,11 @@ # Configuration, paths and CSV (PRA.Common) 'Import-PraConfiguration', 'Test-PraScopeConfiguration', 'New-PraEffectiveConfiguration', 'Get-PraConfigurationDifference', 'Resolve-PraPath', 'Read-PraCsvText', 'Read-PraTargetCsv', 'Get-PraTargetOverride', 'Get-PraToolVersion', 'Get-PraCloudModuleReport', 'Get-PraValue', 'Get-PraList', # Ordinal helpers, JSON and native calls (PRA.Common) - 'Test-PraOrdinalEqual', 'Test-PraOrdinalIgnoreCaseEqual', 'Test-PraOrdinalIn', 'Test-PraOrdinalIgnoreCaseIn', 'Get-PraOrdinalSorted', 'Get-PraOrdinalUnique', 'Compare-PraX500Address', 'ConvertFrom-PraJson', 'Get-PraNativeProcessApi', 'Get-PraWin32ErrorText', + 'Test-PraOrdinalEqual', 'Test-PraOrdinalIgnoreCaseEqual', 'Test-PraOrdinalIn', 'Test-PraOrdinalIgnoreCaseIn', 'Get-PraOrdinalSorted', 'Get-PraOrdinalUnique', 'New-PraRecordIndex', 'Get-PraRecordIndex', 'Find-PraRecord', 'ConvertTo-PraImmutableId', 'Get-PraSourceAnchor', 'Compare-PraX500Address', 'ConvertFrom-PraJson', 'Get-PraNativeProcessApi', 'Get-PraWin32ErrorText', 'Test-PraOwnEntryProcess', # Private folders, phase data and transfer package (PRA.Common) - 'New-PraPrivateDirectorySecurity', 'Initialize-PraPrivateFolder', 'Register-PraObjectName', 'Register-PraObjectBackup', 'Save-PraPhaseData', 'Copy-PraPhaseData', 'Get-PraTransferPackageName', 'Get-PraTransferPackage', 'New-PraTransferPackage', 'Import-PraTransferPackage', + 'New-PraPrivateDirectorySecurity', 'Initialize-PraPrivateFolder', 'Register-PraObjectName', 'Register-PraObjectBackup', 'Save-PraPhaseData', 'Copy-PraPhaseData', 'Copy-PraPhaseFile', 'Test-PraBatchSideFile', 'Write-PraRetentionProof', 'Get-PraRetentionProof', 'Test-PraRetentionCheckRecord', 'Test-PraCloudMailboxKept', 'Get-PraBatchApplyState', 'Get-PraConvertCloudDone', 'Get-PraTransferPackageName', 'Get-PraTransferPackage', 'New-PraTransferPackage', 'Import-PraTransferPackage', # Active Directory, backup and proof (PRA.Directory) - 'Initialize-PraDirectory', 'Initialize-PraPermissionCache', 'Get-PraUser', 'Resolve-PraGroup', 'Get-PraGroupMember', 'Get-PraExpectedX500', 'Get-PraTarget', 'New-PraRow', 'New-PraPlan', 'Invoke-PraAdPreview', 'Invoke-PraAdBatch', 'Invoke-PraAdReplication', 'Invoke-PraSync', 'Test-PraSyncServer', 'Start-PraSyncProbe', 'Import-PraBackup', 'Import-PraProof', 'Assert-PraReceipt', 'Assert-PraFollowupState', 'Get-PraHash', 'Write-PraImmutableFile', 'New-PraPrivateDirectory', 'Write-PraJournal' + 'Initialize-PraDirectory', 'Initialize-PraPermissionCache', 'Get-PraUser', 'Resolve-PraGroup', 'Get-PraGroupMember', 'Get-PraExpectedX500', 'Get-PraTarget', 'Find-PraRecoverOfBatch', 'Get-PraJournalTouchedObject', 'New-PraRow', 'New-PraPlan', 'Invoke-PraAdPreview', 'Invoke-PraAdBatch', 'Invoke-PraAdReplication', 'Invoke-PraSync', 'Test-PraSyncServer', 'Start-PraSyncProbe', 'Import-PraBackup', 'Import-PraProof', 'Assert-PraReceipt', 'Assert-PraCloudProofObject', 'Assert-PraFollowupState', 'Get-PraHash', 'Write-PraImmutableFile', 'New-PraPrivateDirectory', 'Write-PraJournal' ) CmdletsToExport = @() VariablesToExport = @() @@ -45,10 +45,10 @@ } # SIG # Begin signature block -# MIImKgYJKoZIhvcNAQcCoIImGzCCJhcCAQExDzANBglghkgBZQMEAgEFADB5Bgor +# MIImKwYJKoZIhvcNAQcCoIImHDCCJhgCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBdVU0nXaeku7Vm -# eBEshUJPgUC5v7kqQJRJKRVnNoOJNKCCDW8wggZyMIIEWqADAgECAghkM1HTxzif +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCD5QjJDozZr9em1 +# wEM5Q9lh902dMW0WABcdLDLrgf7gW6CCDW8wggZyMIIEWqADAgECAghkM1HTxzif # CDANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx # EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8G # A1UEAwwoU1NMLmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTAe @@ -120,28 +120,28 @@ # ULeH38N0Vr83psiJVuBSxQyt5nRVrpYz7FACq5gtXELkyViq/rGOlJKaRrgQ6WWq # eoIXqKhVFAdP/jAEm2M8ezoVYsUgPyKY2OcuecV9coulAcxUIUydx6qYiOfsGj5u # Dy7l4aYjvB771wkUMzUQwxzcDYXJtMMTaWRe6n9EemR67jc73u5CJ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JVNTTC5jb20gVGltZXN0YW1waW5nIElzc3VpbmcgUlNBIENBIDICEFRD+De9Wu4Y # AYRyuFzajuMwCwYJYIZIAWUDBAIBoIIBYDAaBgkqhkiG9w0BCQMxDQYLKoZIhvcN -# AQkQAQQwHAYJKoZIhvcNAQkFMQ8XDTI2MTExMzEyMTIyNlowKAYJKoZIhvcNAQk0 -# MRswGTALBglghkgBZQMEAgGhCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIIJ/ -# 2wru7lGUjff+GE0EqQ2bQHcvOz6SdowSb+B8oBLrMIHIBgsqhkiG9w0BCRACLzGB +# AQkQAQQwHAYJKoZIhvcNAQkFMQ8XDTI2MTEyMjExMDkxNlowKAYJKoZIhvcNAQk0 +# MRswGTALBglghkgBZQMEAgGhCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIGFS +# fttZPoE7SitUEBPpLAf4qdeuHLCA+yrI9JB6hKUDMIHIBgsqhkiG9w0BCRACLzGB # uDCBtTCBsjCBrwQgV0/qF6r6XnxqK5sIyZixc15FCzhzykTmokygkw5j87AwgYow # dqR0MHIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91 # c3RvbjERMA8GA1UECgwIU1NMIENvcnAxLjAsBgNVBAMMJVNTTC5jb20gVGltZXN0 # YW1waW5nIElzc3VpbmcgUlNBIENBIDICEFRD+De9Wu4YAYRyuFzajuMwCgYIKoZI -# zj0EAwIERzBFAiEA1MBnlQvCWbfbqUx+RhLizspmkoYlcGJKmPKYoIhBLRECIHnI -# swyuUR7gMxdZif1kqPJpQjFcO+lOFmx0q+nPtDfZ +# zj0EAwIESDBGAiEAtqf9DqjRH/E831TC0LQgX087Rf6q9cUDPAjSPNAILmoCIQDk +# b1dwLQSoEhyuwI2eN7vTV4PhjgTw6VdDapBB1ME6IQ== # SIG # End signature block diff --git a/package/PraRemoteMailbox.psm1 b/package/PraRemoteMailbox.psm1 index 4c43b32..05ee6f5 100644 --- a/package/PraRemoteMailbox.psm1 +++ b/package/PraRemoteMailbox.psm1 @@ -18,7 +18,7 @@ .NOTES Author : Nicolas Fabert - Version : 3.1.4 + Version : 3.2.0 History : see CHANGELOG.md #> #Requires -Version 7.5 @@ -51,8 +51,8 @@ Import-Module (Join-Path $PSScriptRoot 'module\PRA.Directory.psm1') -Force -Erro # SIG # Begin signature block # MIImKgYJKoZIhvcNAQcCoIImGzCCJhcCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG -# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDhcx39eedNj3f5 -# XCHeSIYnYCwYUbrJB9+wO2xJKlCeaqCCDW8wggZyMIIEWqADAgECAghkM1HTxzif +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBzDL1szDH2w+mj +# m/7BIDoyBvPc6hveiGwKHwNgEwmSKqCCDW8wggZyMIIEWqADAgECAghkM1HTxzif # CDANBgkqhkiG9w0BAQsFADB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx # EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8G # A1UEAwwoU1NMLmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTAe @@ -129,23 +129,23 @@ Import-Module (Join-Path $PSScriptRoot 'module\PRA.Directory.psm1') -Force -Erro # A1UEAwwrU1NMLmNvbSBDb2RlIFNpZ25pbmcgSW50ZXJtZWRpYXRlIENBIFJTQSBS # MQIQBof4ljXihJpmCqqt2mhAWzANBglghkgBZQMEAgEFAKCBhDAYBgorBgEEAYI3 # AgEMMQowCKACgAChAoAAMBkGCSqGSIb3DQEJAzEMBgorBgEEAYI3AgEEMBwGCisG -# AQQBgjcCAQsxDjAMBgorBgEEAYI3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VQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0b24xETAP # BgNVBAoMCFNTTCBDb3JwMS4wLAYDVQQDDCVTU0wuY29tIFRpbWVzdGFtcGluZyBJ @@ -244,13 +244,13 @@ Import-Module (Join-Path $PSScriptRoot 'module\PRA.Directory.psm1') -Force -Erro # czEQMA4GA1UEBwwHSG91c3RvbjERMA8GA1UECgwIU1NMIENvcnAxLjAsBgNVBAMM # JVNTTC5jb20gVGltZXN0YW1waW5nIElzc3VpbmcgUlNBIENBIDICEFRD+De9Wu4Y # AYRyuFzajuMwCwYJYIZIAWUDBAIBoIIBYDAaBgkqhkiG9w0BCQMxDQYLKoZIhvcN -# AQkQAQQwHAYJKoZIhvcNAQkFMQ8XDTI2MTExMzEyMTIyOVowKAYJKoZIhvcNAQk0 -# MRswGTALBglghkgBZQMEAgGhCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIFll -# gLq5kqWTrLG37IG5AmGeyy7NvEmTFxPCxh8Krht3MIHIBgsqhkiG9w0BCRACLzGB +# AQkQAQQwHAYJKoZIhvcNAQkFMQ8XDTI2MTEyMjExMDkxOVowKAYJKoZIhvcNAQk0 +# MRswGTALBglghkgBZQMEAgGhCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIGBG +# c0aEDG+Qdl0iA3htGuxAFKsUqxK5J6LZgLE7eRt+MIHIBgsqhkiG9w0BCRACLzGB # uDCBtTCBsjCBrwQgV0/qF6r6XnxqK5sIyZixc15FCzhzykTmokygkw5j87AwgYow # dqR0MHIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91 # c3RvbjERMA8GA1UECgwIU1NMIENvcnAxLjAsBgNVBAMMJVNTTC5jb20gVGltZXN0 # YW1waW5nIElzc3VpbmcgUlNBIENBIDICEFRD+De9Wu4YAYRyuFzajuMwCgYIKoZI -# zj0EAwIERzBFAiAJT0WheQcnaZ4CuAde1CVJtdg2xN9W6XWdQytgKrjL1gIhAJ// -# fDRo/pHXsltdstOl7bZSnETQ3KMB2r/9dUvIriIE +# zj0EAwIERzBFAiEAp+GvCo86GKVUQem6NTRJkch9n9NE7sdfNZr+4YRSp20CIFkM +# LV+QaduYlHA11F8eW0P6zudcRQ7dhqpJdP+sfSnH # SIG # End signature block diff --git a/package/README.md b/package/README.md index 8260d8a..c19d15f 100644 --- a/package/README.md +++ b/package/README.md @@ -1,6 +1,6 @@ # PRA Remote Mailbox -When the on-premises Exchange servers are lost, gives every user a mailbox in Exchange Online and rolls everything back when Exchange is available again. PowerShell 7.5+ engine, optional WPF window. Author: Nicolas Fabert. Version 3.1.4. +When the on-premises Exchange servers are lost, gives every user a mailbox in Exchange Online and rolls everything back when Exchange is available again. PowerShell 7.5+ engine, optional WPF window. Author: Nicolas Fabert. Version 3.2.0. This folder contains everything needed to run the tool: `Invoke-PraRemoteMailbox.ps1`, its modules and WPF window, the configuration and CSV samples, the report template and the two guides (user guide and reference guide). Tests and build tools stay outside it, in the repository. diff --git a/package/config/PraRemoteMailbox.config.psd1 b/package/config/PraRemoteMailbox.config.psd1 index 9d3a2bf..fab6baa 100644 --- a/package/config/PraRemoteMailbox.config.psd1 +++ b/package/config/PraRemoteMailbox.config.psd1 @@ -2,7 +2,7 @@ # PRA Remote Mailbox - configuration file # -------------------------------------------------------------------------- # Author : Nicolas Fabert -# Version : 3.1.4 +# Version : 3.2.0 # # This file is read by Invoke-PraRemoteMailbox.ps1. It is a PowerShell data # file: text between quotes, $true / $false, numbers, and @( ) for lists. @@ -147,6 +147,9 @@ CheckLicense = $true # wait for a licence with Exchange enabled (users) MailboxCheckVia = 'Exo' # Exo (mailbox type in Exchange Online) or Graph (provisioning) RequiredSkuPartNumber = '' # '' = any licence with Exchange; e.g. 'SPE_E3' + IdentityCheck = 'Anchor' # Anchor = the Entra ID account must carry the AD source anchor (objectGUID or ms-DS-ConsistencyGuid); Off = accounts are found by UPN only + RetryBudgetObjectSeconds = 180 # most seconds one object waits in retries of throttled or unreachable cloud calls (0 = no retry) + RetryBudgetRunMinutes = 30 # most minutes the whole run waits in retries; used up, the run stops cleanly (0 = no retry) } # Exchange Online module. @@ -167,13 +170,30 @@ # --------------------------------------------------------------------- # Retention tag: written at Convert so that an adaptive scope of a Purview retention policy # keeps the old mailbox (extensionAttributeN on-premises = CustomAttributeN in Exchange Online). - # Recover restores the original value. PolicyGuid is only used by -Action Check -Expect Retained. + # Recover restores the original value. PolicyGuid is used by -Action Check -Expect Retained and by the + # retention check that comes before a Recover. + # CheckBeforeRecover = $true : before it removes the cloud mailboxes, a Recover (Preview and Apply, AD part) reads each mailbox that + # carries the retention tag and checks that the retention policy holds it. The Apply STOPS, before any change, when a + # mailbox is not covered or cannot be checked (for instance PolicyGuid is empty); the Preview says so and the Apply + # is then refused. -AcceptRetentionRisk (a checkbox in the window) goes on for ONE run: the run says so in a warning. + # CheckBeforeRecover = $false: the check is off for every run. Each Recover says so once, in a warning; it never claims the check passed. + # ProofMaxAgeHours : two-server setup. The AD server often cannot ask Exchange Online. A Check -Expect Retained -Batch on the cloud + # server writes a retention proof (RetentionProof-...json and its .sha256 file, in its Backups\Outbox folder). Copied to the + # Backups\Inbox folder of the AD server, it stands in for the check of a Recover (phase AD) when it is intact, of this batch + # and Environment, not older than this many hours (1 to 720), and covers every object of the Recover. Where Exchange Online + # can be asked (phase Both, a certificate sign-in, or an interactive console) its answer decides and the proof is read only + # when Exchange Online cannot be reached. The hours are the setting of the server that reads the proof (the AD server). + # The proof must also be of the same Convert batch file and, when PolicyGuid is set here, of that policy. Only the NEWEST + # proof of the batch counts; an older proof never completes it. Without PolicyGuid here the proof is accepted and the run prints + # the policy GUID the proof names. # --------------------------------------------------------------------- Retention = @{ Enabled = $true PolicyName = 'PRA-Converted-Retention' PolicyGuid = '' # (Get-RetentionCompliancePolicy '').Guid UseComplianceSession = $false # find the GUID from PolicyName (interactive Connect-IPPSSession) + CheckBeforeRecover = $true # $false = no retention check before a Recover + ProofMaxAgeHours = 24 # age limit of a retention proof from the cloud server (1 to 720 hours) Tag = @{ Enabled = $true Attribute = 'extensionAttribute1' diff --git a/package/docs/PraRemoteMailbox-Guide.html b/package/docs/PraRemoteMailbox-Guide.html index f3d351c..8b09486 100644 --- a/package/docs/PraRemoteMailbox-Guide.html +++ b/package/docs/PraRemoteMailbox-Guide.html @@ -184,9 +184,9 @@ main { padding: 0; max-width: none; } .section { break-inside: avoid-page; box-shadow: none; } .part { break-before: page; } } -