SOLVED

Connect to Exchange Online(MFA enabled)

%3CLINGO-SUB%20id%3D%22lingo-sub-236125%22%20slang%3D%22en-US%22%3EConnect%20to%20Exchange%20Online(MFA%20enabled)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236125%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20experts%20i%20am%20using%20exchange%20hybrid%20environment.%20we%20have%20enabled%20MFA%2C%26nbsp%3B%20From%20one%20of%20my%20server%20i%20am%20using%20below%20commands%20on%20windows%20powershell%26nbsp%3B%20to%20connect%20to%20exchange%20online.%20i%20am%20able%20to%20connect%20successfully.%3C%2FP%3E%3CP%3EImport-Module%20%24((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%2B%22%5CApps%5C2.0%5C%22)%20-Filter%20Microsoft.Exchange.Management.ExoPowershellModule.dll%20-Recurse%20).FullName%7C%3F%7B%24_%20-notmatch%20%22_none_%22%7D%7Cselect%20-First%201)%3C%2FP%3E%3CP%3E%24Session%3DNew-ExoPSSession%3CBR%20%2F%3E%3CBR%20%2F%3EImport-PSSession%20%24Session%20-Verbose%20-AllowClobber%3C%2FP%3E%3CP%3EWhen%20i%20execute%20the%20below%20command%20from%20my%20laptop%20from%20windows%20powershell%20i%20am%20getting%20the%20below%20error%3C%2FP%3E%3CP%3E%3CSPAN%3EPS%20C%3A%5CUsers%5Cuser1.MYDOMAIN%26gt%3B%20Import-Module%20%24((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%2B%22%5CApps%5C2.0%5C%22)%20-Filter%20Micr%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3Eosoft.Exchange.Management.ExoPowershellModule.dll%20-Recurse%20).FullName%7C%3F%7B%24_%20-notmatch%20%22_none_%22%7D%7Cselect%20-First%201)%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EImport-Module%20%3A%20Cannot%20bind%20argument%20to%20parameter%20'Name'%20because%20it%20is%20null.%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3EAt%20line%3A1%20char%3A15%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%2B%20...%20port-Module%20%24((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%2B%22%5CApps%5C2.0%5C%22)%26nbsp%3B%20...%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%2B%20CategoryInfo%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3A%20InvalidData%3A%20(%3A)%20%5BImport-Module%5D%2C%20ParameterBindingValidationException%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%2B%20FullyQualifiedErrorId%20%3A%20ParameterArgumentValidationErrorNullNotAllowed%2CMicrosoft.PowerShell.Commands.ImportModul%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3BeCommand%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-236125%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOn-Premises%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-237927%22%20slang%3D%22en-US%22%3ERe%3A%20Connect%20to%20Exchange%20Online(MFA%20enabled)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-237927%22%20slang%3D%22en-US%22%3E%3CP%3EWell%2C%20do%20you%20have%20the%20ExO%20MFA%20module%20installed%20on%20the%20laptop%3F%20If%20so%2C%20what%20does%20the%20following%20resolve%20to%3A%3C%2FP%3E%0A%3CPRE%3E%24((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%2B%22%5CApps%5C2.0%5C%22)%20-Filter%20Microsoft.Exchange.Management.ExoPowershellModule.dll%20-Recurse%20).FullName%7C%3F%7B%24_%20-notmatch%20%22_none_%22%7D%7Cselect%20-First%201)%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-236197%22%20slang%3D%22en-US%22%3ERe%3A%20Connect%20to%20Exchange%20Online(MFA%20enabled)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-236197%22%20slang%3D%22en-US%22%3EIf%20you%E2%80%99ve%20installed%20the%20exo%20powershell%20modular%20on%20the%20machine.%20You%20should%20just%20type%20in%20connect-exo%20and%20hit%20tab.%20Can%E2%80%99t%20rememebr%20off%20top%20head%20it%20auto%20complete%20to%20connect-exosession%20or%20online%20can%E2%80%99t%20recall%20but%20then%20it%20prompts%20threw%20mfa%20etc.%20not%20sure%20if%20there%20is%20a%20reason%20for%20all%20that%20manual%20importing%3F%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

Hi experts i am using exchange hybrid environment. we have enabled MFA,  From one of my server i am using below commands on windows powershell  to connect to exchange online. i am able to connect successfully.

Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse ).FullName|?{$_ -notmatch "_none_"}|select -First 1)

$Session=New-ExoPSSession

Import-PSSession $Session -Verbose -AllowClobber

When i execute the below command from my laptop from windows powershell i am getting the below error

PS C:\Users\user1.MYDOMAIN> Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter Micr
osoft.Exchange.Management.ExoPowershellModule.dll -Recurse ).FullName|?{$_ -notmatch "_none_"}|select -First 1)
Import-Module : Cannot bind argument to parameter 'Name' because it is null.
At line:1 char:15
+ ... port-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\")  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Import-Module], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ImportModul
   eCommand

2 Replies
Highlighted
If you’ve installed the exo powershell modular on the machine. You should just type in connect-exo and hit tab. Can’t rememebr off top head it auto complete to connect-exosession or online can’t recall but then it prompts threw mfa etc. not sure if there is a reason for all that manual importing?
Highlighted
Solution

Well, do you have the ExO MFA module installed on the laptop? If so, what does the following resolve to:

$((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter Microsoft.Exchange.Management.ExoPowershellModule.dll -Recurse ).FullName|?{$_ -notmatch "_none_"}|select -First 1)