Skip to content

Support per module default output formatting (Get-MgUser's and Get-MgBetaUser's UserType property: Now you see it, now you don't) #2144

@alexandair

Description

@alexandair
Contributor

Different versions of SDK and Graph API cause different, inconsistent, behavior for the UserType property.

SDK v1, v1.0 endpoint: Get-MgUser doesn't return UserType by default
SDK v1, beta endpoint: Get-MgUser returns and displays UserType by default

SDK v2, v1.0 endpoint: Get-MgUser doesn't return UserType by default
SDK v2, beta endpoint: Get-MgBetaUser returns UserType, but it's not displayed in the output by default

Behavior also changes when -Property is used, if we get the specified user or list all users

PS> get-mgbetauser -property signinactivity -userid  ac4de573-e369-4dcb-bbd2-170c4a0b667c | select usertype

UserType
--------


PS> get-mgbetauser -property signinactivity | select usertype

UserType
--------
Member
Member
...

Activity

peombwa

peombwa commented on Jul 12, 2023

@peombwa
Member

Thanks for following up on this.

This is a behavior with the API that's reproducible through Graph Explorer as well. Calling the command with -Debug will return the raw HTTP response from the API.

The API does not return all user properties when fetching a single user and signInActivity is exclusively specified in the $select/-Property:
image
vs
image

As a workaround, you can explicitly include userType in the $select/-Property - -property signinactivity, userType.

Please open a question/ticket at https://developer.microsoft.com/en-us/graph/support as this is a service issue. Please include the requestId and date of the affected calls in your ticket/question. See Microsoft Graph PowerShell module troubleshooting guide for more details.

This repository is intended for issues related to the functionality of the module. We may not be the best place to answer some queries that are tied to the functionality of the API.

alexandair

alexandair commented on Jul 12, 2023

@alexandair
ContributorAuthor

@peombwa This is a PowerShell issue:

SDK v2, beta endpoint: Get-MgBetaUser returns UserType, but it's not displayed in the output by default

peombwa

peombwa commented on Jul 12, 2023

@peombwa
Member

@alexandair, this is covered in the known issues - https://github.com/microsoftgraph/msgraph-sdk-powershell#known-issues. Since we use CLR types, only a handful of preselected properties are shown on your terminal by default. You can pipe the command's output to PowerShell's Format-* commands to show all properties/ format the response to your liking.

The change was made as part #2002 to remove the property from the v1.0 response. The output display format config (AutoREST directives) only supports formatting by type names, we can't have unique output display format for v1.0 and beta types:

directive:
  - where:
      model-name: ^MicrosoftGraphUser\d*$
    set:
      format-table:
        properties:
          - DisplayName
          - Id
          - Mail
          - UserPrincipalName
alexandair

alexandair commented on Jul 12, 2023

@alexandair
ContributorAuthor

@peombwa I'm confused now. Why can't we have the same output in SDK v1 and SDK v2 for beta endpoint?

SDK v1, beta endpoint: Get-MgUser returns and displays UserType by default
SDK v2, beta endpoint: Get-MgBetaUser returns UserType, but it's not displayed in the output by default

SDK v1, v1.0 endpoint: Get-MgUser doesn't return UserType by default
SDK v2, v1.0 endpoint: Get-MgUser doesn't return UserType by default

31 remaining items

microsoft-github-policy-service

microsoft-github-policy-service commented on Aug 10, 2023

@microsoft-github-policy-service
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

alexandair

alexandair commented on Aug 10, 2023

@alexandair
ContributorAuthor

What does "as not planned" mean?
This won't be fixed in v3?

peombwa

peombwa commented on Aug 10, 2023

@peombwa
Member

Sorry about that. The issue got closed by error.

I'll rename the title of the issue to "Support per module default output formatting" for discoverability.

changed the title [-]Get-MgUser's and Get-MgBetaUser's UserType property: Now you see it, now you don't[/-] [+]Support per module default output formatting (Get-MgUser's and Get-MgBetaUser's UserType property: Now you see it, now you don't)[/+] on Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alexandair@peombwa@CarolKigoonya

        Issue actions

          Support per module default output formatting (Get-MgUser's and Get-MgBetaUser's UserType property: Now you see it, now you don't) · Issue #2144 · microsoftgraph/msgraph-sdk-powershell