IdentityProtectionTools icon indicating copy to clipboard operation
IdentityProtectionTools copied to clipboard

The term 'Get-MgProfile' is not recognized as the name of a cmdlet

Open RNalivaika opened this issue 2 years ago • 1 comments

PS C:\ > Get-AzureADIPRiskyUser WARNING: Unable to find type [Microsoft.Graph.PowerShell.Authentication.Utilities.DependencyAssemblyResolver]. Get-MgProfile : The term 'Get-MgProfile' 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. At C:\IdentityProtectionTools\Get-AzureADIPRiskyUser.ps1:84 char:18

I guess this is because "Microsoft Graph PowerShell SDK V2" beta features can no longer be accessed directly..

Graph module version info:

PS C:> Get-InstalledModule | Where-Object {$_.name -match 'Microsoft.Graph'} | Select-Object version,name

Version Name


2.4.0 Microsoft.Graph.Authentication
2.4.0 Microsoft.Graph.Groups
2.4.0 Microsoft.Graph.Identity.DirectoryManagement 2.4.0 Microsoft.Graph.Identity.SignIns
2.4.0 Microsoft.Graph.Security
2.4.0 Microsoft.Graph.Users

RNalivaika avatar Nov 16 '23 12:11 RNalivaika

@RNalivaika in:

  • Invoke-AzureADIPDismissRiskyUser.ps1 ln 52
  • Invoke-AzureADIPConfirmCompromisedRiskyUser.ps1 ln 49
  • Get-AzureADIPRiskyUser.ps1 ln 84

You will see the blocks that are throwing. if ((Get-MgProfile).Name -eq 'v1.0') { Write-Warning ("Current MGProfile is set to v1.0, and some cmdlets may need to use the beta profile. Run Select-MgProfile -Name beta to switch to beta API profile") }

These look like they're responsible for simply checking whether or not we're pointed at Graph beta/1.0; cmdlet has been deprecated (https://learn.microsoft.com/en-us/answers/questions/1331741/select-mgprofile-and-get-mgprofile-still-relevant)

When running into this issue, I had commented out these blocks and tested a handful of users. Everything else worked as expected and I ran on >1000 users.

I advise caution, but even if the cmdlet existed this wouldn't have stopped everything from running.

DevinPower avatar Mar 22 '24 03:03 DevinPower