how to connect O365 account using exchange online with MFA enable without login prompt in powershell?

Pavan Patil 21 Reputation points
2022-10-31T18:17:13.147+00:00

I want login to O365 account using exchange online
o365 account has MFA enable
want to login to account without adding credentials to login prompt.

any suggestion will greatly appreciated

Thanks,
Pavan

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,178 questions
Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 119.6K Reputation points MVP Volunteer Moderator
    2022-10-31T18:59:24.68+00:00

    You cannot, that's the whole idea of having MFA - the login attempt must be interactive. Either ask your admins to exclude your account from the MFA requirements (bad practice), add a trusted IP/range so you don't get prompted (better practice) or configure the device as Azure AD Joined (best, as you can use PRT, which counts as MFA). If the idea is to run scripts automatically, use the method outlined here instead: https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.