Unable to connect to Exchange Online (Powershell) with MFA

Iron Contributor

Anyone see this error when attempting to connect to Exchange Online with MFA?

 


out-lineoutput : The method or operation is not implemented.
    + CategoryInfo          : NotSpecified: (:) [out-lineoutput], NotImplementedException
    + FullyQualifiedErrorId : System.NotImplementedException,Microsoft.PowerShell.Commands.OutLineOutputCommand
 

Installed the hybrid exchange module from Exchange Online as I have always done. Also installed other AzureAD and seeing the same error (i.e Get-MSOLuser) 

 

The only thing i believe is different this round was that I installed Powershell 5.1 (and even 6.1.2 thinking it might have been a bug).    Help 

 

11 Replies

Works fine here. Do note however that the MFA module does NOT support PowerShell Core yet, use the "old" version (the one built-in in Windows).

How do I switch to the old version. I am using PS-ISE. Thanks,. 

You shouldn't be using the ISE. When you install the ExO MFA module, it will place a shortcut on your desktop. Use that to launch it, then use the Connect-EXOPSSession cmdlet to connect.

Always used ISE. Plus I have scripts that do more than just EXO.

Nobody is stopping you from using those. But the ExO MFA module is not supported in ISE. There are some methods to get it working, if you insist on that approach. It boils down to finding the location where the click-once package was installed and loading the relevant script from there. So something like this:

 

$targetdir = (dir $env:LOCALAPPDATA"\Apps\2.0\" -Include CreateExoPSSession.ps1,Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse | Group Directory | ? {$_.Count -eq 2}).Values | sort LastWriteTime -Descending | select -First 1 | select -ExpandProperty FullName

 

. $targetdir\CreateExoPSSession.ps1

Hi Jeff,

 

Try importing the module manually. Run the following commands, delineated by the semicolon:

 

$Modules = @(Get-ChildItem -Path "$($env:LOCALAPPDATA)\Apps\2.0" -Filter "Microsoft.Exchange.Management.ExoPowershellModule.manifest" -Recurse );

$ModuleName = Join-path $Modules[0].Directory.FullName "Microsoft.Exchange.Management.ExoPowershellModule.dll";

Import-Module -FullyQualifiedName $ModuleName -Force;

$SessionMFEXO = New-ExoPSSession -ConnectionUri 'https://outlook.office365.com/PowerShell-LiveId' -AzureADAuthorizationEndpointUri 'https://login.windows.net/common';

Import-PSSession $SessionMFEXO -AllowClobber;

 

 

I've tested with PowerShell ISE Host version 5.1.17134.407, which does work.

I had the smililar issue and it turned out to be the old version of MSOnline and AzureAD please try use the below make sure to uninstall old AzureAD if you have one installed.

 

AzureAD V2 module: https://www.powershellgallery.com/packages/AzureAD/2.0.0.131

MSOnline module: https://www.powershellgallery.com/packages/MSOnline/1.1.166.0

 

 

I have a question; why is it possible to view email addresses(Global Address list) from public computers when you login to Microsoft Azure GovCloud with RSA Key? (https://login.microsoftonline.com) . Even more concerning is accessing outlook server, sharepoint and skype. Can someone share any insight?

Sadly none of these have fixed the problem. I can confirm my scripts work with Visual Studio Code. Guess I have to get used to using this instead. Not a bad thing I suppose.  

@Jeff Harlow 

I'm using something I found online similar to what @Vasil Michev  posted earlier. This allows me to establish a MFA enabled EXOPSession from within a script I run via the ISE:

$CreateEXOPSSession = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -ErrorAction SilentlyContinue -Force | Select -Last 1).DirectoryName
. "$CreateEXOPSSession\CreateExoPSSession.ps1"

Connect-EXOPSSession -userprincipalname 

 Hope that helps.

The level of fragmentation in the tooling of PowerShell is amazing...