Get-MgReportEmailActivityUserDetail : A parameter cannot be found that matches parameter name 'UserId

Knut Sander Blakkestad 20 Reputation points
2024-11-26T10:13:59.5266667+00:00

Copied this over from GitHub:

Describe the bug

I am trying to use Get-MgReportEmailActivityUserDetail to get information only about a certain user, using the UserId parameter in the inputObject, but I am recieving the following error.

Get-MgReportEmailActivityUserDetail: 
Line |
   7 |  Get-MgReportEmailActivityUserDetail @inputObject -OutFile 'temp.csv'
     |                                      ~~~~~~~~~~~~
     | A parameter cannot be found that matches parameter name 'UserId'.

The input object looks like this:

$inputObject = @{
    Period = "D90"
    UserId = "name@email.com" 
}

I have tried several other parameters as well, but they also produce the same error.

Expected behavior

UserId is defined as one of the parameters that can be passed to the function in the documentation, so the expected behaviour is that I am allowed to pass it to the function and that it returns a result.

How to reproduce

  1. Connect to Microsoft Graph with at least "Reports.Read.All" privileges.
  2. Create an input object as described above
  3. Run the Get-MgReportEmailActivityUserDetail command with the inputObject and an OutFile.

SDK Version

2.22.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

<details><summary>Click to expand log</summary>


<Log output here>

</details>

Configuration

Name Value
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Other information

No response

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,504 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 109.7K Reputation points MVP
    2024-11-26T17:32:39.3933333+00:00

    As the error message suggests, UserId is not a valid parameter for this call. In fact, none of the Microsoft 365 reports allow you to filter based on userId (only some of the Entra ones do). So any such filtering must be done client-side.

    On PowerShell's side of things, the module uses auto-generated cmdlets, and autogenerated help, which is full of mistakes. I've tried arguing with the Graph folks about this on numerous occasions, doesn't look like things will change. So my advise here is to always check the corresponding Graph API method documentation to get the proper usage. In this case: https://learn.microsoft.com/en-us/graph/api/reportroot-getemailactivityuserdetail?view=graph-rest-1.0&tabs=http


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.