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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions package/Invoke-ExchangeMailboxMigration.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#Requires -Version 5.1

<#
.SYNOPSIS
Exchange Mailbox Migration - moves Exchange Server mailboxes from source databases to target
Expand Down Expand Up @@ -114,6 +115,14 @@
(batches kept on purpose are listed but do not change the code), 3 = cancelled at the
confirmation question (nothing changed).
Documentation : docs\ExchangeMailboxMigration-Guide.md (or .html)

Disclaimer:
This Script is a Personal project.
It's provided "AS-IS". It's not an official Microsoft product so no support can be expected from Microsoft.

As any scripts you must read carefully the documentation and test it first in a Test environment before any run in Production.

Mailbox moves change production data: run the inventory, review the plan, simulate with `-WhatIf` and test in a lab before production use.
#>
[CmdletBinding(SupportsShouldProcess)]
param(
Expand Down
9 changes: 9 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ notepad .\config\ExchangeMailboxMigration.config.psd1 # Databases: source a
Project page, releases and change log: https://github.com/Nico77600/ExchangeMailboxMigration

License: [MIT](LICENSE).

## Disclaimer

This Script is a Personal project.
It's provided "AS-IS". It's not an official Microsoft product so no support can be expected from Microsoft.

As any scripts you must read carefully the documentation and test it first in a Test environment before any run in Production.

Mailbox moves change production data: run the inventory, review the plan, simulate with `-WhatIf` and test in a lab before production use.
36 changes: 36 additions & 0 deletions tests/ExchangeMailboxMigration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,42 @@ AfterAll {
if ($script:Temp -and (Test-Path -LiteralPath $script:Temp)) { Remove-Item -LiteralPath $script:Temp -Recurse -Force }
}

Describe 'Runtime disclaimer' {
BeforeAll {
$script:DisclaimerRepo = Split-Path $PSScriptRoot -Parent
$script:DisclaimerConfig = Get-Content (Join-Path $script:DisclaimerRepo '.github\ci.json') -Raw | ConvertFrom-Json
$script:DisclaimerRuntime = Join-Path $script:DisclaimerRepo $script:DisclaimerConfig.runtimeRoot
$script:DisclaimerPattern = '(?ms)^## Disclaimer[ \t]*\r?\n(?<Body>.*?)(?=^##[ \t]|\z)'
$rootReadme = [IO.File]::ReadAllText((Join-Path $script:DisclaimerRepo 'README.md'))
$matches = [regex]::Matches($rootReadme, $script:DisclaimerPattern)
if ($matches.Count -ne 1) { throw 'The root README must contain exactly one canonical disclaimer.' }
$script:CanonicalDisclaimer = $matches[0].Groups['Body'].Value.Trim().Replace("`r`n", "`n")
function ConvertTo-DisclaimerParagraphs([string]$Text) {
(($Text.Trim() -split '\r?\n[ \t]*\r?\n') | ForEach-Object { ($_ -replace '\s+', ' ').Trim() }) -join "`n`n"
}
}

It 'keeps the runtime README disclaimer identical to the canonical root section' {
$readme = [IO.File]::ReadAllText((Join-Path $script:DisclaimerRuntime 'README.md'))
$matches = [regex]::Matches($readme, $script:DisclaimerPattern)
$matches.Count | Should -Be 1
$matches[0].Groups['Body'].Value.Trim().Replace("`r`n", "`n") | Should -BeExactly $script:CanonicalDisclaimer
}

It 'keeps the public entry script disclaimer attached to its help with the same wording and paragraphs' {
$path = Join-Path $script:DisclaimerRuntime $script:DisclaimerConfig.packageEntry
$errors = $null
$ast = [Management.Automation.Language.Parser]::ParseFile($path, [ref]$null, [ref]$errors)
@($errors).Count | Should -Be 0
$help = $ast.GetHelpContent()
$help | Should -Not -BeNullOrEmpty
$notes = $help.Notes
[regex]::Matches($notes, '(?m)^[ \t]*Disclaimer:[ \t]*$').Count | Should -Be 1
$body = [regex]::Match($notes, '(?s)(?:^|\r?\n)[ \t]*Disclaimer:[ \t]*\r?\n(?<Body>.*)\z').Groups['Body'].Value
(ConvertTo-DisclaimerParagraphs $body) | Should -BeExactly (ConvertTo-DisclaimerParagraphs $script:CanonicalDisclaimer)
}
}

Describe 'Configuration' {
It 'accepts the delivered configuration file' {
$s = Import-EmmConfiguration -Path (Join-Path $script:Root 'config\ExchangeMailboxMigration.config.psd1') -Root $script:Root
Expand Down
Loading