Skip to content

Commit

Permalink
e2g.ps1: ignore but preserve case evaluating mailbox addresses
Browse files Browse the repository at this point in the history
References: GXH-71
  • Loading branch information
WalterHof authored and jengelh committed Oct 26, 2023
1 parent 7efbfc1 commit d36a98f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tools/exchange2grommunio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ $LinuxUser = "root"
# The $LinuxUser password - or use certificate based authentication
$LinuxUserPWD = "Secret_root_Password"

# Import only these mailboxes, an array of mail addresses, $IgnoreMboxes will be honored
# To import all mailboxes leave empty, to import only some mailboxes, populate $ImportMboxes
#[string] $ImportMboxes = '[email protected]','[email protected]'
# Import only these mailboxes, an array of mail addresses, case insensitive,
# $IgnoreMboxes will be honored.
# To import all mailboxes leave empty, to import only some mailboxes, populate
# $ImportMboxes.
#[string] $ImportMboxes = '[email protected]','[email protected]'
[string] $ImportMboxes = ''

# Ignore these mailboxes, an array of mail addresses
[string] $IgnoreMboxes = 'testx1@example.com','testx2@example.com'
# Ignore these mailboxes, an array of mail addresses, case insensitive
[string] $IgnoreMboxes = 'TestX1@example.com','Testx2@example.com'

# Delete .pst files after import to save space.
$DeletePST = $true
Expand Down Expand Up @@ -420,22 +422,22 @@ foreach ($Mailbox in (Get-Mailbox)) {

if ($ImportMboxes.length -gt 5) {
# Use $ImportMboxes only if it contains a minimum of one mail address
if ($ImportMboxes.contains($MigMBox)) {
if ($ImportMboxes.ToLower().contains($MigMBox.ToLower())) {
Write-MLog "Mailbox: $MigMBox found in `$ImportMboxes list." green
} else {
$MailboxesSkipped++
$MailboxesTotal++
Write-MLog "Ignoring mailbox: $MigMBox, mailbox not in `$ImportMboxes list." yellow
continue
} # if ($ImportMboxes.contains($MigMBox))
}
} # if ($ImportMboxes.length -gt 5)

if ($IgnoreMboxes.contains($MigMBox)) {
if ($IgnoreMboxes.ToLower().contains($MigMBox.ToLower())) {
$MailboxesSkipped++
$MailboxesTotal++
Write-MLog "Ignoring mailbox: $MigMBox, found mailbox in `$IgnoreMboxes list." yellow
continue
} # if ($IgnoreMboxes.contains($MigMBox))
}
Write-MLog "" white
# Clean up before exporting a mailbox
# Remove all MailboxExportRequest, to make check for "Completed" more robust
Expand Down

0 comments on commit d36a98f

Please sign in to comment.