Skip to content

Instantly share code, notes, and snippets.

@noahpeltier
Created April 22, 2019 16:28
Show Gist options
  • Save noahpeltier/5f3834285f2704fab45743406a05d858 to your computer and use it in GitHub Desktop.
Save noahpeltier/5f3834285f2704fab45743406a05d858 to your computer and use it in GitHub Desktop.
Connects to Exchange online in a consol
$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