We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Sign out from all Microsoft 365 services

October 05, 2023 Views: 2716

The script signs out the user from all Microsoft 365 services.

To use the script, install modules Microsoft.Graph on the computer where Adaxes service runs.

Edit Remove
PowerShell
$azureId = $Context.TargetObject.AzureID

if ($NULL -eq $azureId)
{
    $Context.LogMessage("User %fullname% does not have an Azure AD account.", "Warning")
    return
}

$accessToken = $Context.CloudServices.GetAzureAuthAccessToken()
Connect-MgGraph -AccessToken ($accessToken | ConvertTo-SecureString -AsPlainText -Force)

Revoke-MgUserSignInSession -UserID $azureId
Comments 4
avatar
mdaniel Jan 27, 2021
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 <ScriptBlock>, <No file>: line 16"
avatar
Support Jan 28, 2021
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.
avatar
Mark Monaco Oct 04, 2023
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 <ScriptBlock>, <No file>: line 12"
avatar
Support Oct 05, 2023
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.
Leave a comment
Loading...

Got questions?

Support Questions & Answers