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

Get-MgUserAuthenticationMethodCount does not exists

Open blackadi opened this issue 1 year ago • 3 comments

Describe the bug

Get-MgUserAuthenticationMethodCount throws 400 bad request error. image

Is this cmdlet available? It is listed in the Microsoft Graph PowerShell documentation, which you can find here

Expected behavior

Get the current count of authentication methods registered to a user using this cmdlet Get-MgUserAuthenticationMethodCount

How to reproduce

Call Get-MgUserAuthenticationMethodCount cmdlet and it will throw 400 bad request error.

SDK Version

2.18.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```

DEBUG: [CmdletBeginProcessing]: - Get-MgUserAuthenticationMethodCount begin processing with parameterSet 'Get'.

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): DEBUG: [Authentication]: - Scopes: [Application.Read.All, Application.ReadWrite.All, AppRoleAssignment.ReadWrite.All, AuditLog.Read.All, Directory.Read.All, Directory.ReadWrite.All, Domain.ReadWrite.All, openid, Policy.Read.All, Policy.ReadWrite.ApplicationConfiguration, profile, User.Read, User.Read.All, User.ReadWrite, User.ReadWrite.All, email].

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): DEBUG: ============================ HTTP REQUEST ============================

HTTP Method: GET

Absolute Uri: https://graph.microsoft.com/v1.0/users/*******/authentication/methods/$count

Headers: FeatureFlag : 00000043 Cache-Control : no-store, no-cache User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.22631; en-US),PowerShell/5.1.22621.3810 Accept-Encoding : gzip SdkVersion : graph-powershell/2.18.0 client-request-id : 0b8ddab4-ad17-443f-a75d-03608c282faa

Body:

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): DEBUG: ============================ HTTP RESPONSE ============================

Status Code: BadRequest

Headers: Transfer-Encoding : chunked Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : decbd03a-5100-4c4f-adc8-655b87c9cc91 client-request-id : 0b8ddab4-ad17-443f-a75d-03608c282faa x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"UAE North","Slice":"E","Ring":"2","ScaleUnit":"002","RoleInstance":"DX3PEPF000000B5"}} Date : Mon, 08 Jul 2024 11:43:57 GMT

Body: { "error": { "code": "UnknownError", "message": "{"ErrorCode":"badRequest","Message":"Resource not found for segment 'users('*********')/authentication/methods/$count'.","Target":null,"Details":null,"InnerError":null,"InstanceAnnotations":[],"TypeAnnotation":null}", "innerError": { "date": "2024-07-08T11:43:57", "request-id": "decbd03a-5100-4c4f-adc8-655b87c9cc91", "client-request-id": "0b8ddab4-ad17-443f-a75d-03608c282faa" } } }

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"):

Confirm {"ErrorCode":"badRequest","Message":"Resource not found for segment 'users('**********')/authentication/methods/$count'.","Target":null,"Details":null,"InnerError":null,"InstanceAnnotations":[],"TypeAnnotation":null}

Status: 400 (BadRequest) ErrorCode: UnknownError Date: 2024-07-08T11:43:57

Headers: Transfer-Encoding : chunked Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : decbd03a-5100-4c4f-adc8-655b87c9cc91 client-request-id : 0b8ddab4-ad17-443f-a75d-03608c282faa x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"UAE North","Slice":"E","Ring":"2","ScaleUnit":"002","RoleInstance":"DX3PEPF000000B5"}} Date : Mon, 08 Jul 2024 11:43:57 GMT

[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): Get-MgUserAuthenticationMethodCount : {"ErrorCode":"badRequest","Message":"Resource not found for segment 'users('***********')/authentication/methods/$count'.","Target":null,"Details":null,"InnerError":null,"InstanceAnnotations":[],"TypeAnnotation":null} Status: 400 (BadRequest) ErrorCode: UnknownError Date: 2024-07-08T11:43:57 Headers: Transfer-Encoding : chunked Vary : Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : decbd03a-5100-4c4f-adc8-655b87c9cc91 client-request-id : 0b8ddab4-ad17-443f-a75d-03608c282faa x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"UAE North","Slice":"E","Ring":"2","ScaleUnit":"002","RoleInstance":"DX3PEPF000000B5"}} Date : Mon, 08 Jul 2024 11:43:57 GMT At line:1 char:1

  • Get-MgUserAuthenticationMethodCount -UserId "*********** ...
  •   + CategoryInfo          : InvalidOperation: ({ UserId = ******... , Headers =  }:<>f__AnonymousType94`4) [Get-MgUserAuthenticationMethodCount_Get], Exception
      + FullyQualifiedErrorId : UnknownError,Microsoft.Graph.PowerShell.Cmdlets.GetMgUserAuthenticationMethodCount_Get
    

DEBUG: [CmdletEndProcessing]: - Get-MgUserAuthenticationMethodCount end processing.

Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"):

</details>


### Configuration

$ $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22621.3810
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.3810
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

### Other information

_No response_

blackadi avatar Jul 08 '24 13:07 blackadi

@blackadi thanks for identifying and reporting this issue. The cmdlet corresponds to this /users/{user-id}/authentication/methods/$count Microsoft Graph Api path which unfortunately I'm not able to trace its reference documentation here. It seems the $count path parameter is not supported; however, I've opened an issue here https://github.com/microsoftgraph/msgraph-metadata/issues/648 for tracking purposes.

timayabi2020 avatar Jul 09 '24 16:07 timayabi2020

@timayabi2020 do you have a feedback if this is supported or not.

blackadi avatar Jul 11 '24 16:07 blackadi

@blackadi I've also run into this issue, it seems that $count used to exist but no longer does (it was at least available when Microsoft.Graph.Beta C# package 5.56.0 was published as I used it then). This endpoint seems to still exist in the latest C# package as well but doesn't work...

matt-gribben avatar Aug 06 '24 08:08 matt-gribben

Related to: https://github.com/microsoftgraph/msgraph-metadata/issues/648

5HT2 avatar Jun 29 '25 15:06 5HT2