ExchangeConnector.ps1


Description

Purpose

Connects to Exchange Online or Exchange On-premises using a script menu.

Detailed Description

The ExchangeConnector function uses the PSMenu module to create a script menu for connecting to Exchange Online or Exchange On-premises. It prompts the user to select an option from the menu and performs the corresponding action based on the selection.

Back to Top

Usage

Example 1

ExchangeConnector

Connects to Exchange Online or Exchange On-premises based on the user’s selection.

Back to Top

Notes

Requires the PSMenu module to be installed. You can install it from the PowerShell Gallery using the following command: Install-Module -Name PSMenu -Scope CurrentUser

Back to Top


Script

<#
.SYNOPSIS
Connects to Exchange Online or Exchange On-premises using a script menu.

.DESCRIPTION
The ExchangeConnector function uses the PSMenu module to create a script menu for connecting to Exchange Online or Exchange On-premises. It prompts the user to select an option from the menu and performs the corresponding action based on the selection.

.PARAMETER None

.INPUTS
None

.OUTPUTS
None

.EXAMPLE
ExchangeConnector
Connects to Exchange Online or Exchange On-premises based on the user's selection.

.NOTES
Requires the PSMenu module to be installed. You can install it from the PowerShell Gallery using the following command:
Install-Module -Name PSMenu -Scope CurrentUser

#>

function ExchangeConnector {

    # Using the PSMenu module to create a script menu
    # Requires PSMenu module to be installed
    # https://www.powershellgallery.com/packages/PSMenu/1.0.0

    # Import the PSMenu module
    Import-Module PSMenu

    # Create a new menu
    $Menu = Show-Menu @("Connect Exchange Online", "Connect Exchange On-prem", $(Get-MenuSeparator), "Quit")

    # Use the correct comparison operator and check the value of $Menu
    if ($Menu -eq "Connect Exchange Online") { Connect-ExchangeOnline -UserPrincipalName (Read-Host "Enter your O365 Admin Email Address") }
    elseif ($Menu -eq "Connect Exchange On-prem") { Connect-ExchangeOnPrem -ComputerName ($(Get-ExchangeServerInSite)[0].fqdn) }
    else { Write-Output "Nothing Selected" }

}

Back to Top

Download

Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.


Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.

Issue


Back to Top