/// <summary>
        /// Run the cmdlet.
        /// </summary>
        protected override void ProcessRecord()
        {
            // Auth
            SdkAuthResult authResult;

#if NETFRAMEWORK
            switch (this.ParameterSetName)
            {
            case ParameterSetPSCredential:
                System.Net.NetworkCredential networkCreds = this.PSCredential.GetNetworkCredential();
                authResult = AuthUtils.AuthWithCredentials(networkCreds.UserName, networkCreds.Password);
                break;

            case ParameterSetCertificate:
                // TODO: Implement Certificate auth
                throw new PSNotImplementedException();

            case ParameterSetForceInteractive:
                authResult = AuthUtils.Auth(Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.SelectAccount);
                break;

            case ParameterSetForceNonInteractive:
                authResult = AuthUtils.Auth(Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior.Never);
                break;

            case ParameterSetAdminConsent:
                authResult = AuthUtils.GrantAdminConsent();
                break;

            default:
                authResult = AuthUtils.Auth();
                break;
            }
#else
            authResult = AuthUtils.AuthWithDeviceCode(
                displayDeviceCodeMessageToUser: (deviceCodeMessage) =>
            {
                this.WriteWarning(deviceCodeMessage);
            },
                useAdminConsentFlow: this.AdminConsent
                );
#endif

            // Decide what to return
            if (!this.Quiet)
            {
                if (this.PassThru)
                {
                    // Return the access token
                    this.WriteObject(authResult.AccessToken);
                }
                else
                {
                    // Return details about the logged in user
                    this.WriteObject(authResult.PSUserDisplayableInformation);
                }
            }
        }