User Tools

Site Tools


wiki:connect_exchange_online_microsoft_powershell

Connect to Exchange Online with Microsoft Powershell

Installing Debian package did not work because of error

This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.

when running

Connect-ExchangeOnline -InlineCredential

Use docker instead:

docker run  \
  -v $HOME:$HOME \
  -v $HOME/.local/share/powershell/:/root/.local/share/powershell/  \
  -v $HOME/.cache/powershell/:/root/.cache/powershell/  \
  -it mcr.microsoft.com/azure-powershell pwsh
Install-Module -Name ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement

If you are using username and password run these steps

$UserCredential = Get-Credential

Then input your credentials:

PS /> $UserCredential = Get-Credential
 
PowerShell credential request
Enter your credentials.
User: user@example.com
Password for user user@example.com: ****************

Connect to exchange:

Connect-ExchangeOnline -Credential $UserCredential

If you are using the MFA setup run this command

Connect-ExchangeOnline -Device

The command returns a URL and unique code that's tied to the session. You need to open the URL in a browser on any computer, and then enter the unique code. After you complete the login in the web browser, the session in the Powershell 7 window is authenticated via the regular Azure AD authentication flow, and the Exchange Online cmdlets are imported after few seconds.

Test connection

Get-Mailbox

It should return a list of mailboxes.

Tested on

  • Docker 19.03.8
  • Ubuntu 20.04.
  • Powershell 7.1.3.-1

See also

References

wiki/connect_exchange_online_microsoft_powershell.txt · Last modified: 2021/04/11 11:17 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki