Skip to content

Instantly share code, notes, and snippets.

@soulhakr
Last active January 23, 2023 17:39
Show Gist options
  • Save soulhakr/f8f6f0eef60cd13feb6a4b578665a4b1 to your computer and use it in GitHub Desktop.
Save soulhakr/f8f6f0eef60cd13feb6a4b578665a4b1 to your computer and use it in GitHub Desktop.
[Import Exchange Online modules for ISE (Powershell)] description #powershell #windows
## Connect to Exchange Online with MFA in ISE
## documentation: https://docs.microsoft.com/en-us/powershell/exchange/v1-module-mfa-connect-to-exo-powershell?view=exchange-ps
## tutorial: https://www.youtube.com/watch?v=EnmwLqdtDCM
## Download and install cmdlets from - https://docs.microsoft.com/en-us/powershell/exchange/exchange-online-powershell?view=exchange-ps
## NOTE: this method will eventually be retired - the newer method is here: https://docs.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps
Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA + '\Apps\2.0\') -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse ).FullName | Where-Object { $_ -notmatch '_none_' } | Select-Object -First 1)
$EXOSession = New-ExoPSSession
Import-PSSession $EXOSession
<#
# NOTE:
# Be sure to disconnect the remote PowerShell session when you're finished. If you close the Exchange
# Online Remote PowerShell Module window without disconnecting the session, you could use up all the
# remote PowerShell sessions available to you, and you'll need to wait for the sessions to expire.
# To disconnect all currently open PowerShell sessions in the current window, run the following command:
#
# Get-PSSession | Remove-PSSession
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment