Skip to content

Find-MgGraphCommand sometimes fails on URI #1370

Closed

Description

@PowerBugi

Hello,

I don't know if it's a bug, but sometime when i try to get the cmdlet from the Graph URL, it give me an error : URI is not valid or is not currently supported by the SDK.
But in fact if i do some research, the cmdlet exist, and if i use the Find-MgGraphCommand -Command with the cmldet i found, it work.
But if i want to reverse the search with Find-MgGraphCommand -Uri it fail.

To be clear, here's one example :

if i do : Find-MgGraphCommand -Command Get-MgReportSharePointActivityUserCount
it give me :

PS C:\bugi > Find-MgGraphCommand -Command Get-MgReportSharePointActivityUserCount

   APIVersion: v1.0

Command                                 Module  Method URI                                                         OutputType Permissions Variants
-------                                 ------  ------ ---                                                         ---------- ----------- --------
Get-MgReportSharePointActivityUserCount Reports GET    /reports/getSharePointActivityUserCounts(period='{period}')            {}          {Get, GetViaIdentity}

   APIVersion: beta

Command                                 Module  Method URI                                                         OutputType Permissions Variants
-------                                 ------  ------ ---                                                         ---------- ----------- --------
Get-MgReportSharePointActivityUserCount Reports GET    /reports/getSharePointActivityUserCounts(period='{period}')            {}          {Get1, GetViaIdentity1}

And now, if i reverse it like : Find-MgGraphCommand -Uri "/reports/getSharePointActivityUserCounts(period='{period}')"
it give me :

PS C:\bugi > Find-MgGraphCommand -Uri "/reports/getSharePointActivityUserCounts(period={period})"
Find-MgGraphCommand: URI ' https://graph.microsoft.com/v1.0/reports/getSharePointActivityUserCounts(period={period})' in  is not valid or is not currently supported by the SDK. Ensure the URI is formatted correctly and try again.

So I sometimes tend to believe that the cmdlet i search does not yet exist, whereas if...
Thanks for your help.

Activity

  1. peombwa commented on Jul 7, 2022

    @peombwa
    Member

    Thanks for bringing this to our attention!

    This is indeed a bug with Find-MgGraphCommand when attempting to match the parenthesis in the provided OData function.
    As a workaround, you can use regex in the URL to find any OData actions and functions with parenthesis as such:

    F:\M> Find-MgGraphCommand -Uri "/reports/getSharePointActivityUserCounts.*"
    
       APIVersion: v1.0
    
    Command                                 Module  Method URI                                                         OutputType Permissions        Variants
    -------                                 ------  ------ ---                                                         ---------- -----------        --------
    Get-MgReportSharePointActivityUserCount Reports GET    /reports/getSharePointActivityUserCounts(period='{period}')            {Reports.Read.All} {Get, GetViaIdentity}
    
       APIVersion: beta
    
    Command                                 Module  Method URI                                                         OutputType Permissions        Variants
    -------                                 ------  ------ ---                                                         ---------- -----------        --------
    Get-MgReportSharePointActivityUserCount Reports GET    /reports/getSharePointActivityUserCounts(period='{period}')            {Reports.Read.All} {Get1, GetViaIdentity1}

    We will address this in upcoming releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions