Hi,
Using 2.1.6, there is an error in function Install-DCMicrosoftGraphPowerShellModule where the currently installed Microsoft.Graph modules are always removed and reimported into the current PowerShell session.
This of course causes any already signed in sessions to be removed and this always forces Enable-DCEntraIDPIMRole to always request signing using Device Code - Line 1180 in the .psm1 file.
The Remove-Module should not be run here and be moved inside the "Upgrade" else if clause.
Removing the module, causes the if (!(Get-MgContext)) check in Enable-DCEntraIDPIMRole to always be true, so forces device code sign in.
With this change, connecting to Graph as a user before running Enable-DCEntraIDPIMRole works again as expected and not using Device Code auth every time.
Answer to issue #52
-Heine Jeppesen
Cloud Architect @ APENTO