I need to use Connect-MSolservice to list MFA enabled accounts. Does Connect-MSolservice support using Service Principal Account for authentication?
1 Answer
Shortly Yes It supports. But not in all version!
When attempting to use Connect-MsolService with an MFA-enabled admin account you may receive a legacy authentication prompt instead of modern authentication prompt.
Legacy prompt will fail authentication request as it does not support modern authentication and requires either MFA disabled or application password. This incorrect prompt is due to older version of MSOnline PowerShell module being installed on the machine.
To fix this issue, you need to ensure you have the latest version installed for MSOnline module
Run below power shell command to install new version, make sure you are running the powershell as admin
C:\> Install-Module -Name MSOnline
See the screen shot below:
Once the updated module is installed, you will need to close and reopen PowerShell window. With a new PowerShell window open, run the Connect-MsolService cmdlet. This time you will see a new modern authentication prompt that will let you go thorugh MFA authentication process without any issues
Note: PowerShell 1.0 is not supported for your case, so you do have to uninstall 1.0 before implementing above process
For more information you could have a look on following article
-
Thanks .. do you have a snippet sample on how to connect using the Service Principal? .. I couldn't find any reference that MSolservice supports SP for authentication. Apr 19, 2019 at 9:40
-
@GiulioAstori Yeah, The link I have shared have step to step snippet. Please have a look on that. I hope it will help you. Apr 19, 2019 at 9:45
-
The original post is about using a Service Principal account. This post on SO suggests that a service principal account will not work with Connect-MsolService: stackoverflow.com/questions/55747310/… Dec 4, 2019 at 18:45
-