Replies: 7 comments 5 replies
-
Hi @merill I just saw your Graph tips webinar, which led me here. I have written a very similar script to this to clear users' MFA methods. I wrote it using an App Reg and application permissions that are accessed via a front end tool so that our Service desk can clear users' MFA methods. I have identified a couple of instances where this script will not work and in fact, for one of these instances, I'm having an issue as well, since I see no programmatic way to clear a user's MFA methods. Suppose a user has the authenticator app configured as their default method as well as a primary and alternate mobile phone configured. More importantly though, if a user has both a primary and alternate mobile phone and they then specify their alternate mobile phone as their default method, then we have a catch 22. And I've tried to delete these methods in the portal as well, with the same results. The only way to actually resolve the issue for the user is to "require re-register multi-factor authentication" in the portal. This was easily completed programmatically in the past using "Set-MSOLUser -StrongAuthenticationMethods @()", but since this is now deprecated, there is currently no way to do it programatically. Do you have any idea if this is a known issue and whether it will be addressed to allow deletion in this instance? Or maybe we can just get access to the "require re-register multi-factor authentication" flag via graph? Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello @merill, thank you for this script. Just to note that "Remove-MgUserAuthenticationWindowHelloForBusinessMethod" in the script should be "Remove-MgUserAuthenticationWindowsHelloForBusinessMethod" instead. |
Beta Was this translation helpful? Give feedback.
-
@merill I'd recommend setting |
Beta Was this translation helpful? Give feedback.
-
This was probably a typo on the part of Microsoft's devs. To delete Windows Hello for Business methods the correct cmdlet includes the singular word "Window" not "Windows" (module version 1.27.0): Remove-MgUserAuthenticationWindowHelloForBusinessMethod |
Beta Was this translation helpful? Give feedback.
-
Since VS Code called it out, I have to ask the question. What is the purpose of the $result variable? |
Beta Was this translation helpful? Give feedback.
-
Hi @merill, thanks for this script. I noticed that this script seems to experience an error when there are multiple authentication methods but the default device is the phone?
Is this a limitation of the api, the script or is there something I could do to prevent the issue? I know your code has these segments
I confirmed that the script runs flawlessly after modifying the user's default method away from the phone. For clarity, when I say the script errors, I mean that it terminates not allowing it to further process the request. Here is the output after switching the default method from phone to TOTP:
Again, thank you for sharing this script! |
Beta Was this translation helpful? Give feedback.
-
You might need to run the script a few times. It's a problem with the API when it comes to deleting auth methods that are the default. |
Beta Was this translation helpful? Give feedback.
-
Copy this code into a new .ps1 file and run the .ps1 file.
Note that an error is displayed if the default auth method is being deleted before the other methods. The script tracks it and performs a final cleanup at the end to delete the default method.
A final check is run to confirm that all auth methods for the user have been deleted.
Beta Was this translation helpful? Give feedback.
All reactions