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-MgUserMailFolderMessage : Syntax error: character '0' is not valid at position #402

Closed
daveschafer opened this issue Sep 25, 2020 · 2 comments

Comments

@daveschafer
Copy link

I try to use the Microsoft.Graph Module to periodically search for specific mails in a mailbox.
When I filter the output with the "Search" parameter, the query breaks when I have characters like numbers or control characters.

This Example Works:

Get-MgUserMailFolderMessage -UserId "mailbox@domain.tld" -MailFolderId "Inbox" -Search 'Backup Config'

And Provides the expected output:

Id                            Subject                                          ReceivedDateTime      HasAttachments
--                            -------                                          ----------------      --------------
RandomIDString                [Success] Backup Configuration Job (1 VMs)       25.09.2020 08:04:28   False

This Examples do not work:

Get-MgUserMailFolderMessage -UserId "mailbox@domain.tld" -MailFolderId "Inbox" -Search 'Backup Config 0'

Get-MgUserMailFolderMessage -UserId "mailbox@domain.tld" -MailFolderId "Inbox" -Search '\'

Get-MgUserMailFolderMessage -UserId "mailbox@domain.tld" -MailFolderId "Inbox" -Search '_'

And provide this error output:

Get-MgUserMailFolderMessage : Syntax error: character '0' is not valid at position 14 in 'Backup Config 0'.
In Zeile:1 Zeichen:1
+ Get-MgUserMailFolderMessage -UserId "mailbox@domain.tld" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: ({ UserId = back...ndProperty =  }:<>f__AnonymousType5`10) [Get-MgUserMailFolderMessage_List], RestException`1
    + FullyQualifiedErrorId : RequestBroker--ParseUri,Microsoft.Graph.PowerShell.Cmdlets.GetMgUserMailFolderMessage_List

I am not sure if this behaviour is intended and I could not find any hints to that in the documentation.

However there are some workarounds to get the output i want, but therefore I have to first pull a huge list of mails and filter them afterwards, which is painfully slow

@ghost ghost added the ToTriage label Sep 25, 2020
@daveschafer
Copy link
Author

Just found out my issue is tightly related to this one #399

If I quote my double quotes witha single quotes, everything works as expected, e.g.

Get-MgUserMailFolderMessage -UserId "mailbox@domain.tld" -MailFolderId "Inbox" -Search '"Backup Config 0"'

Anyway, it would be nice if the SDK handled this behaviour

@ddyett ddyett added this to the 1.1.0 milestone Sep 30, 2020
@ddyett ddyett added Bug and removed ToTriage labels Sep 30, 2020
This was referenced Oct 26, 2020
@peombwa peombwa modified the milestones: 1.1.0, 1.2.0 Nov 18, 2020
@peombwa
Copy link
Member

peombwa commented Dec 3, 2020

This has been fixed in version 1.2.0. Use Update-Module Microsoft.Graph to install the latest version.

@peombwa peombwa closed this as completed Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants