From c544743ce78a0d4ef0d904b793bca4decb1a1db9 Mon Sep 17 00:00:00 2001 From: "Jeremy D. Berkleef" Date: Fri, 29 Oct 2021 11:25:35 +0200 Subject: [PATCH] Rename alias-toolkit to exchange-toolkit because of added functionality --- .../{alias-toolkit.md => exchange-toolkit.md} | 12 +++++++---- README.md | 2 +- alias-toolkit.ps1 => exchange-toolkit.ps1 | 20 ++++++++++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) rename Docs/{alias-toolkit.md => exchange-toolkit.md} (84%) rename alias-toolkit.ps1 => exchange-toolkit.ps1 (82%) diff --git a/Docs/alias-toolkit.md b/Docs/exchange-toolkit.md similarity index 84% rename from Docs/alias-toolkit.md rename to Docs/exchange-toolkit.md index 38c2dc9..fa0c742 100644 --- a/Docs/alias-toolkit.md +++ b/Docs/exchange-toolkit.md @@ -1,5 +1,5 @@ -# Alias Toolkit - ## How to use Alias Toolkit +# Exchange Toolkit + ## How to use Exchange Toolkit 1. Download the script or clone this repository 2. Make sure the execution policy is set properly (Or run Set-ExecutionPolicy Bypass -Scope Process) 3. Run the script. @@ -9,7 +9,7 @@ > >_If target is Exchange Online, run from a PS session that has already connected to Exchange Online Management Shell._ - ## Alias Toolkit Options + ## Exchange Toolkit Options ### 1. List contents of a .csv Use this option to verify that your .csv file containing email addresses is formatted correctly. The output should look like: @@ -35,4 +35,8 @@ > ***This won't give you a .csv you can apply by default, this is by design. You need to replace the spaces with ; in the EmailAddresses column. This was implemented to ensure double-checking no unwanted addresses are included into the import.*** ### 4. Use the legacy search script and output the alias list to console. - This does the same as the above option, but outputs the results to console with some nice-ish formatting. This is an adaptation of search-email-addresses. \ No newline at end of file + This does the same as the above option, but outputs the results to console with some nice-ish formatting. This is an adaptation of search-email-addresses. + + ### 5. Export a series of mailboxes to .pst + This has only been tested against On-Prem Exchange. + This option will export the mailboxes found via the search term to a .pst. For some reason, Exchange requires a UNC path for the export. \ No newline at end of file diff --git a/README.md b/README.md index 14cdf5c..ae06ffa 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repo contains various scripts used for management tasks (and migrations) on Exchange Server (and Exchange Online). You can click on the script name to see documentation for it. # Scripts -- [**Alias Toolkit**](Docs/alias-toolkit.md) - Easy to use, menu-based script for searching for, exporting and importing aliases from/to Exchange (Online). +- [**Exchange Toolkit**](Docs/exchange-toolkit.md) - Easy to use, menu-based script for automating multiple tedious tasks in Exchange (Online). - **Spam Filter Deployment Script** - Script to create the Connector and Enhanced Filtering rule for a spam gateway. - **Mass Spam Filter Deployment Script** - Script to use delegated Partner (CSP) domains and deploy Connector and Enhanced Filtering rule for a spam gateway. - **List alias .csv contents** - _This has been integrated into Alias Toolkit._ diff --git a/alias-toolkit.ps1 b/exchange-toolkit.ps1 similarity index 82% rename from alias-toolkit.ps1 rename to exchange-toolkit.ps1 index 4dfc798..2453f6e 100644 --- a/alias-toolkit.ps1 +++ b/exchange-toolkit.ps1 @@ -1,6 +1,6 @@ function Show-Menu { param ( - [string]$Title = 'Alias Toolkit by Jeremy Berkleef' + [string]$Title = 'Exchange Toolkit by Jeremy Berkleef' ) Clear-Host Write-Host -ForegroundColor Green "================ $Title ================" @@ -21,6 +21,10 @@ Write-Host -ForegroundColor Cyan " '4' " -NoNewline Write-Host "to use the legacy search script and output the alias list to console." + Write-Host "5: Press" -NoNewline + Write-Host -ForegroundColor Cyan " '5' " -NoNewline + Write-Host "to export a list of mailboxes to .pst based on a search term." + Write-Host "Q: Press" -NoNewline Write-Host -ForegroundColor Red " 'Q' " -NoNewline Write-Host "to quit." @@ -108,6 +112,20 @@ do } } } + + '5' { + Write-Host -ForegroundColor Blue -BackgroundColor White "For exporting a single mailbox, prepend a * to the mailbox name (e.g. *mailbox@example.com)" + $searchTerm = Read-Host -Prompt "Search Query" + Write-Host -ForegroundColor Blue -BackgroundColor White "Path must be in UNC format for Exchange to export to." + $savePath = Read-Host -Prompt "Export Path" + $mailboxes = get-mailbox | Where-Object {$_.EmailAddresses -like "$searchTerm"} + + Foreach ($mailbox in $mailboxes) { + #Concatenate the save path and the mailbox alias. + $exportPath = Join-Path $savePath $mailbox.Alias + New-MailboxExportRequest -Mailbox $mailbox -FilePath "$exportPath.pst" + } + } } Read-Host -Prompt 'Press Enter to Continue' }