<# .SYNOPSIS Checks if the ExchangeOnlineManagement module is installed and installs it if not. .DESCRIPTION This function checks if the ExchangeOnlineManagement module is installed on the system. If the module is not installed, it installs it using the Install-Module cmdlet. .OUTPUTS [bool] Returns $true if the module is already installed or if it is successfully installed, otherwise returns $false. .EXAMPLE Check-ExchangeOnlineManagementModule Checks if the ExchangeOnlineManagement module is installed and installs it if not. #> function Check-ExchangeOnlineManagementModule { # Check if the module is already installed $moduleInstalled = Get-Module -ListAvailable -Name ExchangeOnlineManagement if ($moduleInstalled) { Write-Output "ExchangeOnlineManagement module is already installed." return $true } else { # Install the module try { Install-Module -Name ExchangeOnlineManagement -Force -AllowClobber -Scope CurrentUser -ErrorAction Stop Import-Module ExchangeOnlineManagement -ErrorAction Stop Write-Output "ExchangeOnlineManagement module has been successfully installed." return $true } catch { Write-Output "Failed to install the ExchangeOnlineManagement module." return $false } } } # Usage example for the Check-ExchangeOnlineManagementModule function Check-ExchangeOnlineManagementModule