0 votes

I have the following PowerShell code running in a Custom Command with the Microsoft.Graph v2.6.1 PowerShell Modules installed in the AllUsers scope of the Adaxes Service Server.

$UserId = try { [Guid]$Context.TargetObject.Get("adm-AzureID") } catch {}

try {
    if($null -eq $UserId) {
        throw 'User does not seem to be in Azure AD'
    }
    #Import-Module Microsoft.Graph
    Connect-MgGraph -AccessToken ($Context.CloudServices.GetAzureAuthAccessToken("https://graph.microsoft.com/") | ConvertTo-SecureString -AsPlainText -Force) -NoWelcome
    if(-not (Revoke-MgUserSignInSession -UserId $UserId)) {
        $Context.Cancel("Failed to revoke Azure User sessions.")
    }
} catch {
    # Exception
    $Context.Cancel("An exception has occured: $($_.Exception.Message)")
}

Unfortunately, it produces the warning Selected Microsoft Graph profile 'v1.0' does not exist for module 'Microsoft.Graph.Users.Actions'. No cmdlets were loaded. and then the exception 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.. Import the Module (as per that comment, either before or after Connect-MgGraph) does nothing.

If I open my own PowerShell 5.1 instance, outside of Adaxes, on the same server, then take an AccessToken created by that GetAzureAuthAccessToken() function and use it to connect with Microsoft Graph using Connect-MgGraph, I can use Revoke-MgUserSignInSession in said session without any problems.

by (210 points)

1 Answer

+1 vote
by (289k points)
selected by
Best answer

Hello,

It looks like you have multiple versions of the MgGraph module installed on the computer where Adaxes service runs which results into the behavior you are facing. To remedy the issue, remove all the currently installed versions of the module and install the latest version.

0

You are right, we migrated to PSResourceGet recently and it broke our clean up script. Thank you.

Related questions

0 votes
1 answer

Is in Adaxes used (soon deprecated) AzureAD module for managing Azure/ Office 365 somewhere? Or is it using Microsoft Graph SDK module completely?

asked Feb 27, 2023 by KIT (960 points)
0 votes
1 answer

Hi I'm trying to add your report from here but whenever I run it, I get 2 errors for each user which seem to correspond to the following 2 lines in the ... "user" $Context.DirectorySearcher.AddCriteria($criteria) But I still get the same error's. Thanks Matt

asked Oct 16, 2023 by chappers77 (2.0k points)
0 votes
1 answer

Hi team, currently the loading of "My managed objects" is timing out for some users after exact 1 minute with error DevTools showing me 504 Timing I assume its because of ... users each time I open homepage its loading again and again and take some times.

asked Dec 20, 2023 by wintec01 (1.5k points)
0 votes
1 answer

With the changes in 2018.1, I was wondering if it's possible to use AAD PowerShell v2. I know that it was previously not supported.

asked Jun 29, 2018 by dtb147 (290 points)
0 votes
1 answer

Good afternoon, I'm currently updating some of our scripts and I'm looking to have an option that delete's a users V2 profile path when run. All the scripts I've ... is a script or option available to complete this task, or if you need further clarification.

asked Jan 26, 2015 by jtop (700 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users