Script repository
The script signs out the user from all Microsoft 365 services. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.
To use the script, install Microsoft.Graph on the computer where Adaxes service runs.
$azureId = $Context.TargetObject.AzureID
if ($NULL -eq $azureId)
{
$Context.LogMessage("User %fullname% does not have an Entra ID account.", "Warning")
return
}
$accessToken = $Context.CloudServices.GetAzureAuthAccessToken()
Connect-MgGraph -AccessToken ($accessToken | ConvertTo-SecureString -AsPlainText -Force)
Revoke-MgUserSignInSession -UserID $azureId
Comments 4
You must be signed in to comment.
mdaniel
Hmm. While executing this as part of a deprovisioning script, I receive the following error:
"One or more errors occurred.: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application. Stack trace: at , : line 16"
Support
Hello,
The error message occurs because the target user is not present in the scope of the Microsoft 365 tenant in Adaxes. As a result retrieving the tenant credentials fails and user interaction is required. If you still face issues using the script in your Custom Command for user deprovisioning, please, send us (support[at]adaxes.com) a screenshot of the command.
Mark Monaco
I made sure that the "Microsoft.Graph.Identity.SignIns" was installed on the server that we have Adaxes installed and running from. However, when the script was invoked in our termination process, it produced the following error: "The term 'Revoke-MgUserSignInSession' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. Stack trace: at , : line 12"
Support
Hello,
The issue occurs because of the changes in Microsoft Graph PowerShell module. To use the script, you need to install the full module. Thank you for pointing out the issue, we updated the script description accordingly.