From 746b632235908c820e22319729ec20043b08bdc9 Mon Sep 17 00:00:00 2001 From: AdminDroid <49208841+admindroid-community@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:23:07 +0530 Subject: [PATCH] Install and Connect to EXO Install and Connect to EXO --- .../InstallAndConnectEXO.ps1 | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Install and Connect to EXO/InstallAndConnectEXO.ps1 diff --git a/Install and Connect to EXO/InstallAndConnectEXO.ps1 b/Install and Connect to EXO/InstallAndConnectEXO.ps1 new file mode 100644 index 0000000..66891a3 --- /dev/null +++ b/Install and Connect to EXO/InstallAndConnectEXO.ps1 @@ -0,0 +1,31 @@ +<# +============================================================================================= +Name: Install EXO V3 module and connects to Exchange Online PowerShell +Version: 3.0 +Website: M365scripts.com +For detailed Script execution: https://m365scripts.com/exchange-online/connect-to-exchange-online-powershell/ +============================================================================================ +#> + + +#Due RPS and Basic Auth retirement in Exchange Online, we need EXO V3 module +$Module = (Get-Module ExchangeOnlineManagement -ListAvailable) | where {$_.Version.major -ge 3} +if($Module.count -eq 0) +{ + Write-Host Exchange Online PowerShell V3 module is not available -ForegroundColor yellow + $Confirm= Read-Host Are you sure you want to install module? [Y] Yes [N] No + if($Confirm -match "[yY]") + { + Write-host "Installing Exchange Online PowerShell module" + Install-Module ExchangeOnlineManagement -Repository PSGallery -AllowClobber -Force + Import-Module ExchangeOnlineManagement + } + else + { + Write-Host EXO V3 module is required to connect Exchange Online. Please install module using Install-Module ExchangeOnlineManagement cmdlet. + Exit + } +} + +Write-Host Connecting to Exchange Online... +Connect-ExchangeOnline \ No newline at end of file