msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Find-MgGraphCommand Error when -ApiVersion "beta"

Open BohrenAn opened this issue 1 year ago • 1 comments

Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:

  • Make sure you can reproduce this issue using the latest released version of Microsoft.Graph or Microsoft.Graph.Beta.
  • Please search the existing issues to see if there has been a similar issue filed.
  • For issues related to authentication and service errors, please refer to our troubleshooting guide. For service issues, please open a question at https://developer.microsoft.com/graph/support.

Describe the bug

A clear and concise description of what the bug is. Find-MgGraphCommand gives an Error when -ApiVersion "beta" is used

Find-MgGraphCommand -Command "Get-MgUser" -ApiVersion "beta" Find-MgGraphCommand : 'Get-MgUser' is not a valid Microsoft Graph PowerShell command. Please check the name and try again. At line:1 char:1

  • Find-MgGraphCommand -Command "Get-MgUser" -ApiVersion "beta"
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Find-MgGraphCommand
    
    

image

To Reproduce Steps to reproduce the behavior: Find-MgGraphCommand -Command "Get-MgUser" -ApiVersion "v1.0" Find-MgGraphCommand -Command "Get-MgUser" -ApiVersion "beta"

Expected behavior

A clear and concise description of what you expected to happen. Find-MgGraphCommand returns the Commands when -ApiVersion "beta" is used

Debug Output

Run the problematic command with -Debug and paste the resulting debug stream below. ⚠ ATTENTION: Be sure to remove any sensitive information that may be in the logs. Find-MgGraphCommand -Command "Get-MgUser" -ApiVersion "beta" -Debug Find-MgGraphCommand : 'Get-MgUser' is not a valid Microsoft Graph PowerShell command. Please check the name and try again. At line:1 char:1

  • Find-MgGraphCommand -Command "Get-MgUser" -ApiVersion "beta" -Debug
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Find-MgGraphCommand
    
    

image

Module Version

Please run Get-Module Microsoft.Graph* after cmdlet execution and paste the output below. If a module cannot be installed or imported, please run Get-Module -ListAvailable and paste the output. Get-Module Microsoft.Graph*

ModuleType Version Name ExportedCommands


Script 2.13.1 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G.

Environment Data

Please run $PSVersionTable and paste the output below. If running the Docker container image, indicate the tag of the image used and the version of Docker engine.

$PSVersionTable

Name Value


PSVersion 5.1.22621.2506 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.22621.2506 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

BohrenAn avatar Feb 10 '24 11:02 BohrenAn

Hi @BohrenAn, Profile switch was available on Microsoft Graph PowerShell V1. With the current version, the modules were split where cmdlets with MgBeta noun prefix are now responsible for handling requests to Microsoft Graph beta endpoints while cmdlets with Mg noun prefix are responsible for handling Microsoft Graph v1.0 endpoints.

I would use the Find-MgGraphCommand as below

Find-MgGraphCommand -Command Get-MgUser Find-MgGraphCommand -Command Get-MgBetaUser

image

However, thank you for highlighting that -ApiVersion parameter usage which in this case should not even be there.

timayabi2020 avatar Feb 10 '24 16:02 timayabi2020