I'm working on a way to enable MFA for AAD / O365 users. I'm referring to this article from the MS docs:
https://docs.microsoft.com/en-us/azure/active-directory/authentication/howto-mfa-userstates
If I install the MSOnline module, import it, and connect-msolservice with PS version 5.1 it works as described. If I try to do this with PS version 6.2 I get:
Connect-MsolService : Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
Is this because PS 6.2 is built on .Net Core and it isn't able to load the libraries for a prior version of .Net that's part of the MSOnline module?
What I'm really after is a way to automate enabling MFA for AAD / O365 users, and I'm thinking about using an Azure Function App with PowerShell. This seems like good way to knit this together with our ITSM system calling a web hook made available via the Function App. Obviously there's some the permission and security elements to be worked out to do this. However, if I can't load the MSOnline module to PS 6.2, which is the PS platform available as a Function App, I don't think it would work to use a PowerShell Function App.