Skip to content

Feature Request: -As parameter to cast objects to a type as part of the query #1055

Closed

Description

Synopsis

Some cmdlets like get-mggroupmember support an additional REST path to specify the type of object to return instead of just DirectoryObject
https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http#example-4-use-searchand-odata-cast-to-get-user-membership-in-groups-with-display-names-that-contain-the-letters-pr-including-a-count-of-returned-objects
(Example #4)

Recommended Implementation

Support a -As parameter that either has an enum or just takes a string of supported types that will append this to the request URI, and type it to the same appropriate type in powershell models.

Workaround

[MicrosoftGraphUser1[]]$result = (Invoke-MgGraphRequest -uri 'v1.0/groups/68216d21-752a-4241-8782-d58a960724a3/members/microsoft.graph.user?$select=userprincipalname').Value

Activity

  1. peombwa commented on Mar 31, 2022

    @peombwa
    Member

    Justin Grote (@JustinGrote). Thanks for taking the time to open this issue. Your proposal of adding a -As parameter of the derived types as an enum sounds like a good idea. We will first need to implement #19, then add -As parameter to all commands that support OData cast.

    The SDK does not currently support OData cast due to a lack of derived types in the CSDL metadata/OpenAPI file. We are tracking OData cast support via OpenAPI discriminator in #19.

  2. added this to the v3 milestone on Jun 29, 2022
  3. peombwa commented on Apr 7, 2023

    @peombwa
    Member

    Closing as duplicate of https://github.com/microsoftgraph/microsoft-graph-devx-api/issues/1228.

    The implementation will be something like Get-MgGroupMemberAsUser due to how the API is structured and what's supported by the code generator.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions