Created
April 22, 2019 16:28
-
-
Save noahpeltier/5f3834285f2704fab45743406a05d858 to your computer and use it in GitHub Desktop.
Connects to Exchange online in a consol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SessionParams = @{ | |
ConfigurationName = "Microsoft.Exchange" | |
ConnectionUri = "https://outlook.office365.com/powershell-liveid/" | |
Credential = $Credential | |
Authentication = "Basic" | |
AllowRedirection = $true | |
} | |
Try { | |
Write-Host "Creating session to $($SessionParams.ConnectionUri)" -ForegroundColor Cyan | |
$Global:Session = New-PSSession @SessionParams | |
} | |
Catch { | |
Write-Host "Failed to create Session" -ForegroundColor Red | |
Write-Host $_ -ForegroundColor Yellow | |
break | |
} | |
Try { | |
Write-Host "Importing Session" -ForegroundColor Cyan | |
Import-PSSession $Session -DisableNameChecking -AllowClobber | |
} | |
Catch { | |
Write-Host "Start Session Failed" -ForegroundColor Red | |
Write-Host $_ -ForegroundColor Yellow | |
break | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment