r/PowerShell • u/--LamboRambo-- • Apr 27 '26
Detecting if a user has completed AAD MFA
Hi all,
I have written a PowerShell script that opens up Company Portal (Intune app) to complete MFA upon first login so that OneDrive will silently sync and all that jazz. It works ok but I'd like to make a custom dialog that changes when MFA completion is detected. Right now, I am detecting the OneDrive login, but it takes a couple of minutes to happen after MFA, and I would like it to be a bit quicker at the detection. Is there a token or anything that would change after the MFA is completed by said user?
Thanks for your time.
18
u/baron--greenback Apr 27 '26
Not without using graph api but and honestly sounds like you are needlessly reinventing the wheel.
4
u/Master-IT-All Apr 27 '26
Microsoft already has a solution (Registration Campaign) to encourage or force users to register for MFA, and with Entra P1 you also have a central report view to tell you who has enrolled.
2
u/Phx86 Apr 27 '26
Really curious what the need for quicker detection is. I recently migrated over a thousand users to another MS Tenant and we just ran a report twice a day. If on demand reporting is needed I have a script I could share.
2
u/SolidKnight Apr 28 '26
You would need to create an Entra Id app that limits your script to reading MFA details via the Graph API but even then, I don't think it's a good idea to have a script with non-interactive permission to user authentication information running on every endpoint you have.
2
u/fdeyso Apr 28 '26
You can literally just see user registration events….
AzureAD/Security/Authentication Methods/RegistrationAndResetEvents and just filter Activity Type.
1
u/rogueit Apr 28 '26
You ca hit authenticationMethods with graph to see if they’ve updated their stuff