<# .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
Herstellen einer Verbindung zu Exchange Online mit PowerShell
Herstellen einer Verbindung ohne Proxy
$Cred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell/ -Credential $cred -Authentication Basic -AllowRedirection
import-PSSession $Session
Herstellen einer Verbindung mit Proxy
$Cred = Get-Credential
$proxysettings = New-PSSessionOption -ProxyAccessType IEConfig
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell/ -Credential $cred -Authentication Basic -AllowRedirection -SessionOption $proxysettings
import-PSSession -AllowClobber $Session