Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-MgUserMailFolder Not Returning Items #2771

Closed
12Knocksinna opened this issue Jun 2, 2024 · 2 comments
Closed

Get-MgUserMailFolder Not Returning Items #2771

12Knocksinna opened this issue Jun 2, 2024 · 2 comments
Labels
type:bug A broken experience

Comments

@12Knocksinna
Copy link

Describe the bug

using

Get-MgUserMailFolder -MailFolderId $FolderId -UserId $UserId -All

Returns: Get-MgUserMailFolder: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.

-All is a valid parameter per https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.mail/get-mgusermailfoldermessage?view=graph-powershell-1.0 and has worked in previous versions of the SDK

Using

Get-MgUserMailFolder -MailFolderId $FolderId -UserId $UserId

returns a single object

d ChildFolderCount DisplayName IsHidden ParentF
olderId


AAMkADAzNzBmMzU0LTI3NTItNDQzNy04NzhkLWNmMGU1MzEwYThkNAAuAAAAAAB_7ILpFNx8TrktaK8VYWerAQBe9CuwLc2fTK7W46L1SAp9AABSsNguAAA= 0 Audits False AAMkAD…

Despite the fact that there are many other objects in the folder, as proven by running

$uri = ("https://graph.microsoft.com/v1.0/users/{0}/mailfolders/{1}/Messages/?`$top=999" -f $UserId, $Folderid)
$Data = Invoke-MgGraphRequest -Method get -Uri $Uri
$Data.value.count
999

Expected behavior

Running Get-MgUserMailFolder -MailFolderId $FolderId -UserId $UserId -All should return all messages in a folder.

How to reproduce

See above steps

SDK Version

SDK V2.19

Latest version known to work for scenario above?

In the past - probably V2.13

Known Workarounds

Use the Graph API request.

Debug output

DEBUG: [CmdletBeginProcessing]: - Get-MgUserMailFolder begin processing with parameterSet 'Get'.
DEBUG: [Authentication]: - AuthType: 'AppOnly', TokenCredentialType: 'ClientCertificate', ContextScope: 'Process', AppName: 'Mailbox Reporting App'.
DEBUG: [Authentication]: - Scopes: [User.Read.All, Mail.Read].
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://graph.microsoft.com/v1.0/users/eff4cd58-1bb8-4899-94de-795f656b4a18/mailFolders/AAMkADAzNzBmMzU0LTI3NTItNDQzNy04NzhkLWNmMGU1MzEwYThkNAAuAAAAAAB_7ILpFNx8TrktaK8VYWerAQBe9CuwLc2fTK7W46L1SAp9AABSsNguAAA%3D

Headers:
FeatureFlag : 00000043
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.22631; en-IE),PowerShell/7.4.2
Accept-Encoding : gzip
SdkVersion : graph-powershell/2.19.0
client-request-id : 48a3cfbd-290c-40ba-99ea-99b16fcc2cb9

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control : private
Strict-Transport-Security : max-age=31536000
request-id : 478c9497-4ed1-4b2e-bb79-d3660f7f5efa
client-request-id : 48a3cfbd-290c-40ba-99ea-99b16fcc2cb9
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"North Europe","Slice":"E","Ring":"4","ScaleUnit":"009","RoleInstance":"DU2PEPF00026065"}}
Date : Sun, 02 Jun 2024 21:15:51 GMT

Body:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('eff4cd58-1bb8-4899-94de-795f656b4a18')/mailFolders/$entity",
"id": "AAMkADAzNzBmMzU0LTI3NTItNDQzNy04NzhkLWNmMGU1MzEwYThkNAAuAAAAAAB_7ILpFNx8TrktaK8VYWerAQBe9CuwLc2fTK7W46L1SAp9AABSsNguAAA=",
"displayName": "Audits",
"parentFolderId": "AAMkADAzNzBmMzU0LTI3NTItNDQzNy04NzhkLWNmMGU1MzEwYThkNAAuAAAAAAB_7ILpFNx8TrktaK8VYWerAQBe9CuwLc2fTK7W46L1SAp9AAAA2lIQAAA=",
"childFolderCount": 0,
"unreadItemCount": 0,
"totalItemCount": 23576,
"sizeInBytes": 152787469,
"isHidden": false
}

DEBUG: [CmdletEndProcessing]: - Get-MgUserMailFolder end processing.
Id ChildFolderCount DisplayName IsHidden ParentF
olderId


AAMkADAzNzBmMzU0LTI3NTItNDQzNy04NzhkLWNmMGU1MzEwYThkNAAuAAAAAAB_7ILpFNx8TrktaK8VYWerAQBe9CuwLc2fTK7W46L1SAp9AABSsNguAAA= 0 Audits False AAMkAD…

Configuration

$psversiontable

Name Value


PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.22631
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

@12Knocksinna 12Knocksinna added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jun 2, 2024
@petrhollayms
Copy link

Hi @12Knocksinna ,

Looking at the cmdlet documentation, it returns either one selected folder or lists all folders, not both at the same time:
https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.mail/get-mgusermailfolder?view=graph-powershell-1.0
The user's mail folders. Read-only. Nullable.

If you use -All but omit the -MailFolderId parameter, it uses this endpoint:
https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders?view=graph-rest-1.0&tabs=http

Get-MgUserMailFolderMessage cmdlet shall return messages in the selected folder: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.mail/get-mgusermailfoldermessage?view=graph-powershell-1.0

@petrhollayms petrhollayms added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jun 3, 2024
@12Knocksinna
Copy link
Author

Yep. Brain fart. Complete and utter brain fart. Put it down to advanced age and close this out.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants