OfficeDev / O365-InvestigationTooling

MIT License
574 stars 360 forks source link

MFA #40

Open alastaircupples opened 6 years ago

alastaircupples commented 6 years ago

having issues running this with MFA enabled

Eu2 commented 5 years ago

Same

TechsUK commented 5 years ago

I think app password makes it work , but this could do with being updated for MFA.

drogfild commented 5 years ago

This really should be updated to support MFA

PsychoData commented 5 years ago

I have been trying to look at rebuilding the modules to support MFA, unfortunately the best way to make MFA Work right now is to use the Exchange Online Hyrbid module.

In a browser supporting ClickOnce Applications, you can visit the MS shortlink http://aka.ms/exopspreview to install it . (It isn't still in preview, but I can't get someone at MS to make me a version that doesn't have preview in the URL) Or, if you don't like following redirected shortlinks from random dudes on GitHub, head to https://outlook.office365.com/ecp -> Hybrid on bottom Left -> Configure Exchange Online Powershell Module and install it that way

Then, once you have that ClickOnce Application installed, basically anytime it says

$ExoSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $userCredential -Authentication Basic -AllowRedirection
Import-PSSession $ExoSession

Replace that with opening the Microsoft Exchange Online Powershell Module from your start menu.

I have this, as a in-progress method to load the module into any Powershell session, once that module from the link above is installed, though there are some commands that I haven't finished determining the purpose of or how to best replicate yet, so your-mileage-may-vary (Mostly related to reconnection or sessions, it looks like )


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

    $EXOSession = New-ExoPSSession -UserPrincipalName ("$UserPrincipalName")
    Import-PSSession $EXOSession -DisableNameChecking -AllowClobber 
}
Start-ExoPSSessionCmdlets
PsychoData commented 5 years ago

Speaking of rebuilding it to support MFA -

Would it be an acceptable solution to try to connect through the normal way ($ExoSession = New-PSSession ....; Import-PSSession $ExoSession ) and if that fails then try to load the Powershell Module I listed above?

Or, we could look to see if the Exo Powershell Module is already installed, and use that if it is, and if not, try the $ExoSession = New-PSSession ....; Import-PSSession $ExoSession way, and suggest to install the module if it needs to?

jasc76 commented 5 years ago

please look into this... MFA is crucial

leibishr commented 5 years ago

it works using the app password

djhayes1994 commented 4 years ago

I was able to get this to work with MFA using the following for line 41 to 45:

First, let's get us a cred!

Connect-EXOPSSession

This connects to Azure Active Directory

Connect-MsolService