Skip to content

Get-MgUserMailFolderMessage : Syntax error: character '0' is not valid at position #402

Closed

Description

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

Activity

  1. daveschafer commented on Sep 25, 2020

    @daveschafer
    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

  2. added this to the 1.1.0 milestone on Sep 30, 2020
  3. peombwa commented on Dec 3, 2020

    @peombwa
    Member

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

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions