none
Change Categories via powershell (Not working) RRS feed

  • Question

  • Hi

    I made this script to put some emails into Categories. Where it looks at the Email, and the messageID.

    But iam getting a error


    using this plugin: https://www.powershellgallery.com/packages/Exch-Rest/3.6


    Script: 

    $messages = Import-Csv -Path c:\temp\123.csv
    
    Connect-EXRMailbox -Mailbox "DOP@test.com"
    ForEach ($message in $messages){
    $MessageId = $message.messageID
    $MailboxName = $message.Email
        $Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId 
         Set-EXRItemCategory -MailboxName $MailboxName -Item $Item -Categories @("red")
    
    }
    CSV:
    "messageID","Email"
    "HE1P192MB00423281AEEA3C8F5EC4CC20D1D80@HE1P192MB0042.EURP192.PROD.OUTLOOK.COM;testmail@test.com"

    Error:
    Version             : 1.1
    Content             : System.Net.Http.StreamContent
    StatusCode          : BadRequest
    ReasonPhrase        : Bad Request
    Headers             : {[Transfer-Encoding, System.String[]], [request-id, System.String[]], [client-request-id, System.String[]], [x-ms-ags-diagnostic, System.String[]]...}
    RequestMessage      : Method: PATCH, RequestUri: 'https://graph.microsoft.com/v1.0/users('DOP@
    test.com.
    ')/messages('')', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
                          {
                            Accept: application/json
                            X-AnchorMailbox: DOP@test.com
                            User-Agent: RestClient/1.1
                            Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IkFRQUJBQUFBQUFDNXVuYTBFVUZnVElGOEVsYXh0V2pURXhKVDVVbHZaS0V2aWxpQjZsTFhUTFBTSVFlWmRuVkVpZ01TbThZZzlxRWt3OHhNS2c5V1lsM
                          2o5VlpSZldtNkwwMUNnaGxZSUJETkhycEhSXzhCTVNBQSIsImFsZyI6IlJTMjU2IiwieDV0Ijoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIiwia2lkIjoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIn0.eyJhdW
                          QiOiJodHRwczovL0dyYXBoLk1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9iMTg3NWNkOC1hMzliLTQxYzctYTRhOC02MDFmNDNjNWEyMTIvIiwiaWF0IjoxNTQyNjM1NzE4LCJuYmYiOjE
                          1NDI2MzU3MTgsImV4cCI6MTU0MjYzOTYxOCwiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFWUUFxLzhKQUFBQUMvVU94ekJrOGVqSTQrKzY1QldabTZWVmhGNnN1emNqUXlLUDZSazgyc2UrNDBnL2ROeHcrY1lnK2k2V2py
                          TkdoSUNOK1dzWUdwUE85NTIzemJsaWNST3Y2SVhhMU9veTVLQUlOUkphb3UwPSIsImFtciI6WyJwd2QiLCJyc2EiLCJtZmEiXSwiYXBwX2Rpc3BsYXluYW1lIjoiRXhjaC1SRVNUIFBvd2Vyc2hlbGwgTW9kdWxlIFJlZ2lzd
                          HJhdGlvbiBGdWxsIEFjY2VzcyIsImFwcGlkIjoiNTQ3MTAzMGQtZjMxMS00YzVkLTkxZWYtNzRjYTg4NTQ2M2E3IiwiYXBwaWRhY3IiOiIwIiwiZGV2aWNlaWQiOiI4YjBkMWNkMy0xNDBmLTQ3NjMtOGZiZi1jODE5OGVjND
                          g3ZTYiLCJmYW1pbHlfbmFtZSI6Ik9wcGVubMOmbmRlciIsImdpdmVuX25hbWUiOiJEYW5pZWwiLCJpcGFkZHIiOiIyMTIuMTAuMTcyLjIzMSIsIm5hbWUiOiJEYW5pZWwgT3BwZW5sw6ZuZGVyIFtBdmlhbl0iLCJvaWQiOiI
                          0NmRhZGFlYy01M2Y2LTQyODMtYTM5MC0xOGU5YWZlZDE5YTEiLCJwbGF0ZiI6IjMiLCJwdWlkIjoiMTAwM0JGRkRBNTJFNTZENCIsInNjcCI6IkFjY2Vzc1Jldmlldy5SZWFkLkFsbCBBY2Nlc3NSZXZpZXcuUmVhZFdyaXRl
                          LkFsbCBBZ3JlZW1lbnQuUmVhZC5BbGwgQWdyZWVtZW50LlJlYWRXcml0ZS5BbGwgQWdyZWVtZW50QWNjZXB0YW5jZS5SZWFkIEFncmVlbWVudEFjY2VwdGFuY2UuUmVhZC5BbGwgQWxsU2l0ZXMuUmVhZCBBcHBDYXRhbG9nL
                          lJlYWRXcml0ZS5BbGwgQXVkaXRMb2cuUmVhZC5BbGwgQm9va2luZ3MuTWFuYWdlLkFsbCBCb29raW5ncy5SZWFkLkFsbCBCb29raW5ncy5SZWFkV3JpdGUuQWxsIEJvb2tpbmdzQXBwb2ludG1lbnQuUmVhZFdyaXRlLkFsbC
                          BDYWxlbmRhcnMuUmVhZCBDYWxlbmRhcnMuUmVhZC5BbGwgQ2FsZW5kYXJzLlJlYWQuU2hhcmVkIENhbGVuZGFycy5SZWFkV3JpdGUgQ2FsZW5kYXJzLlJlYWRXcml0ZS5BbGwgQ2FsZW5kYXJzLlJlYWRXcml0ZS5TaGFyZWQ
                          gQ29udGFjdHMuUmVhZCBDb250YWN0cy5SZWFkLkFsbCBDb250YWN0cy5SZWFkLlNoYXJlZCBDb250YWN0cy5SZWFkV3JpdGUgQ29udGFjdHMuUmVhZFdyaXRlLkFsbCBDb250YWN0cy5SZWFkV3JpdGUuU2hhcmVkIERldmlj
                          ZS5Db21tYW5kIERldmljZS5SZWFkIERldmljZU1hbmFnZW1lbnRBcHBzLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRBcHBzLlJlYWRXcml0ZS5BbGwgRGV2aWNlTWFuYWdlbWVudENvbmZpZ3VyYXRpb24uUmVhZC5BbGwgR
                          GV2aWNlTWFuYWdlbWVudENvbmZpZ3VyYXRpb24uUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50TWFuYWdlZERldmljZXMuUHJpdmlsZWdlZE9wZXJhdGlvbnMuQWxsIERldmljZU1hbmFnZW1lbnRNYW5hZ2VkRGV2aW
                          Nlcy5SZWFkLkFsbCBEZXZpY2VNYW5hZ2VtZW50TWFuYWdlZERldmljZXMuUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkLkFsbCBEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkV3JpdGUuQWxsIERldml
                          jZU1hbmFnZW1lbnRTZXJ2aWNlQ29uZmlnLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRTZXJ2aWNlQ29uZmlnLlJlYWRXcml0ZS5BbGwgRGlyZWN0b3J5LkFjY2Vzc0FzVXNlci5BbGwgRGlyZWN0b3J5LlJlYWQuQWxsIERp
                          cmVjdG9yeS5SZWFkV3JpdGUuQWxsIEVBUy5BY2Nlc3NBc1VzZXIuQWxsIEVkdUFkbWluaXN0cmF0aW9uLlJlYWQgRWR1QWRtaW5pc3RyYXRpb24uUmVhZFdyaXRlIEVkdUFzc2lnbm1lbnRzLlJlYWQgRWR1QXNzaWdubWVud
                          HMuUmVhZEJhc2ljIEVkdUFzc2lnbm1lbnRzLlJlYWRXcml0ZSBFZHVBc3NpZ25tZW50cy5SZWFkV3JpdGVCYXNpYyBFZHVSb3N0ZXIuUmVhZCBFZHVSb3N0ZXIuUmVhZEJhc2ljIEVkdVJvc3Rlci5SZWFkV3JpdGUgZW1haW
                          wgRXhjaGFuZ2UuTWFuYWdlIEZpbGVzLlJlYWQgRmlsZXMuUmVhZC5BbGwgRmlsZXMuUmVhZC5TZWxlY3RlZCBGaWxlcy5SZWFkV3JpdGUgRmlsZXMuUmVhZFdyaXRlLkFsbCBGaWxlcy5SZWFkV3JpdGUuQXBwRm9sZGVyIEZ
                          pbGVzLlJlYWRXcml0ZS5TZWxlY3RlZCBGaW5hbmNpYWxzLlJlYWRXcml0ZS5BbGwgZnVsbF9hY2Nlc3NfYXNfdXNlciBHcm91cC5SZWFkLkFsbCBHcm91cC5SZWFkV3JpdGUuQWxsIElkZW50aXR5UHJvdmlkZXIuUmVhZC5B
                          bGwgSWRlbnRpdHlQcm92aWRlci5SZWFkV3JpdGUuQWxsIElkZW50aXR5Umlza0V2ZW50LlJlYWQuQWxsIGlkZW50aXR5cmlza3l1c2VyLnJlYWQuYWxsIE1haWwuUmVhZCBNYWlsLlJlYWQuQWxsIE1haWwuUmVhZC5TaGFyZ
                          WQgTWFpbC5SZWFkV3JpdGUgTWFpbC5SZWFkV3JpdGUuQWxsIE1haWwuUmVhZFdyaXRlLlNoYXJlZCBNYWlsLlNlbmQgTWFpbC5TZW5kLkFsbCBNYWlsLlNlbmQuU2hhcmVkIE1haWxib3hTZXR0aW5ncy5SZWFkIE1haWxib3
                          hTZXR0aW5ncy5SZWFkV3JpdGUgTWVtYmVyLlJlYWQuSGlkZGVuIE5vdGVzLkNyZWF0ZSBOb3Rlcy5SZWFkIE5vdGVzLlJlYWQuQWxsIE5vdGVzLlJlYWRXcml0ZSBOb3Rlcy5SZWFkV3JpdGUuQWxsIE5vdGVzLlJlYWRXcml
                          0ZS5DcmVhdGVkQnlBcHAgTm90aWZpY2F0aW9ucy5SZWFkV3JpdGUuQ3JlYXRlZEJ5QXBwIG9mZmxpbmVfYWNjZXNzIG9wZW5pZCBQZW9wbGUuUmVhZCBQZW9wbGUuUmVhZC5BbGwgUGVvcGxlLlJlYWRXcml0ZSBQb2xpY3ku
                          UmVhZC5BbGwgUG9saWN5LlJlYWRXcml0ZS5Db25kaXRpb25hbEFjY2VzcyBQcml2aWxlZ2VkQWNjZXNzLlJlYWRXcml0ZS5BenVyZUFEIFByaXZpbGVnZWRBY2Nlc3MuUmVhZFdyaXRlLkF6dXJlUmVzb3VyY2VzIHByb2Zpb
                          GUgUHJvZ3JhbUNvbnRyb2wuUmVhZC5BbGwgUHJvZ3JhbUNvbnRyb2wuUmVhZFdyaXRlLkFsbCBSZXBvcnRzLlJlYWQuQWxsIFNlY3VyaXR5RXZlbnRzLlJlYWQuQWxsIFNlY3VyaXR5RXZlbnRzLlJlYWRXcml0ZS5BbGwgU2
                          l0ZXMuRnVsbENvbnRyb2wuQWxsIFNpdGVzLk1hbmFnZS5BbGwgU2l0ZXMuUmVhZC5BbGwgU2l0ZXMuUmVhZFdyaXRlLkFsbCBTdWJzY3JpcHRpb24uUmVhZC5BbGwgVGFza3MuUmVhZCBUYXNrcy5SZWFkLlNoYXJlZCBUYXN
                          rcy5SZWFkV3JpdGUgVGFza3MuUmVhZFdyaXRlLlNoYXJlZCBVc2VyLkV4cG9ydC5BbGwgVXNlci5JbnZpdGUuQWxsIFVzZXIuUmVhZCBVc2VyLlJlYWQuQWxsIFVzZXIuUmVhZEJhc2ljLkFsbCBVc2VyLlJlYWRXcml0ZSBV
                          c2VyLlJlYWRXcml0ZS5BbGwgVXNlckFjdGl2aXR5LlJlYWRXcml0ZS5DcmVhdGVkQnlBcHAgVXNlclRpbWVsaW5lQWN0aXZpdHkuV3JpdGUuQ3JlYXRlZEJ5QXBwIiwic2lnbmluX3N0YXRlIjpbImttc2kiXSwic3ViIjoiN
                          zNyZzI3OEFBVG1uU0ZNS05XMUhJYTduZXduNG5UWUdsYVo1S3Y2cVlxUSIsInRpZCI6ImIxODc1Y2Q4LWEzOWItNDFjNy1hNGE4LTYwMWY0M2M1YTIxMiIsInVuaXF1ZV9uYW1lIjoiZG9wQGF2aWFuLmRrIiwidXBuIjoiZG
                          9wQGF2aWFuLmRrIiwidXRpIjoiUWU0elFodGdkVVdMVVV6UHpvZExBQSIsInZlciI6IjEuMCIsIndpZHMiOlsiNjJlOTAzOTQtNjlmNS00MjM3LTkxOTAtMDEyMTc3MTQ1ZTEwIl0sInhtc190Y2R0IjoxNTA3MTg5ODcyfQ.
                          IvwD1ow-aHTE_OIyiCk7QFmRUAbPY6WaFBdyXouiG7fu8WJxmtgIp2D2yzyzA3P5fAs34PPH7tNcsyOJBWQlUSbTXjML_T5X_Y8xiC0sJlXK5RpQ1ftCicLyo4MuCp7Z5Yx7V7Q3yLZ5hIYuAMBa_jbAzBqM9tOnqR8pa56fx
                          DLanqqikJVJ5cpEemZRc4QyY2B9shbIpxlu9r5kokkbzkDguaPT-jrPtLivlKr8MuCZ11ToDHTdjqj78S6mjR7PoWV649knPoBoVUzSdvUzxHi6XskwyYheQtmQQsF6Q0T_1lntsbbPoogDaFi-xH83KwVn7INhpGUkl0GQUw
                          -BMw
                            Content-Type: application/json; charset=utf-8
                            Content-Length: 26
                          }
    IsSuccessStatusCode : False
    
    Result                 : {
                               "error": {
                                 "code": "ErrorInvalidIdEmpty",
                                 "message": "Id must be non-empty.",
                                 "innerError": {
                                   "request-id": "b9b322d4-d731-4ae5-9adf-53662f9c6a39",
                                   "date": "2018-11-19T14:00:19"
                                 }
                               }
                             }
    Id                     : 27919
    Exception              : 
    Status                 : RanToCompletion
    IsCanceled             : False
    IsCompleted            : True
    CreationOptions        : None
    AsyncState             : 
    IsFaulted              : False
    AsyncWaitHandle        : System.Threading.ManualResetEvent
    CompletedSynchronously : False
    
    Error making REST Patch BadRequest : Bad Request
    Version             : 1.1
    Content             : System.Net.Http.StreamContent
    StatusCode          : BadRequest
    ReasonPhrase        : Bad Request
    Headers             : {[Transfer-Encoding, System.String[]], [request-id, System.String[]], [client-request-id, System.String[]], [x-ms-ags-diagnostic, System.String[]]...}
    RequestMessage      : Method: PATCH, RequestUri: 'https://graph.microsoft.com/v1.0/users('DOP@
    test.com.
    ')/messages('')', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
                          {
                            Accept: application/json
                            X-AnchorMailbox: DOP@
    test.com.
                            User-Agent: RestClient/1.1
                            Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IkFRQUJBQUFBQUFDNXVuYTBFVUZnVElGOEVsYXh0V2pURXhKVDVVbHZaS0V2aWxpQjZsTFhUTFBTSVFlWmRuVkVpZ01TbThZZzlxRWt3OHhNS2c5V1lsM
                          2o5VlpSZldtNkwwMUNnaGxZSUJETkhycEhSXzhCTVNBQSIsImFsZyI6IlJTMjU2IiwieDV0Ijoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIiwia2lkIjoid1VMbVlmc3FkUXVXdFZfLWh4VnRESkpaTTRRIn0.eyJhdW
                          QiOiJodHRwczovL0dyYXBoLk1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9iMTg3NWNkOC1hMzliLTQxYzctYTRhOC02MDFmNDNjNWEyMTIvIiwiaWF0IjoxNTQyNjM1NzE4LCJuYmYiOjE
                          1NDI2MzU3MTgsImV4cCI6MTU0MjYzOTYxOCwiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFWUUFxLzhKQUFBQUMvVU94ekJrOGVqSTQrKzY1QldabTZWVmhGNnN1emNqUXlLUDZSazgyc2UrNDBnL2ROeHcrY1lnK2k2V2py
                          TkdoSUNOK1dzWUdwUE85NTIzemJsaWNST3Y2SVhhMU9veTVLQUlOUkphb3UwPSIsImFtciI6WyJwd2QiLCJyc2EiLCJtZmEiXSwiYXBwX2Rpc3BsYXluYW1lIjoiRXhjaC1SRVNUIFBvd2Vyc2hlbGwgTW9kdWxlIFJlZ2lzd
                          HJhdGlvbiBGdWxsIEFjY2VzcyIsImFwcGlkIjoiNTQ3MTAzMGQtZjMxMS00YzVkLTkxZWYtNzRjYTg4NTQ2M2E3IiwiYXBwaWRhY3IiOiIwIiwiZGV2aWNlaWQiOiI4YjBkMWNkMy0xNDBmLTQ3NjMtOGZiZi1jODE5OGVjND
                          g3ZTYiLCJmYW1pbHlfbmFtZSI6Ik9wcGVubMOmbmRlciIsImdpdmVuX25hbWUiOiJEYW5pZWwiLCJpcGFkZHIiOiIyMTIuMTAuMTcyLjIzMSIsIm5hbWUiOiJEYW5pZWwgT3BwZW5sw6ZuZGVyIFtBdmlhbl0iLCJvaWQiOiI
                          0NmRhZGFlYy01M2Y2LTQyODMtYTM5MC0xOGU5YWZlZDE5YTEiLCJwbGF0ZiI6IjMiLCJwdWlkIjoiMTAwM0JGRkRBNTJFNTZENCIsInNjcCI6IkFjY2Vzc1Jldmlldy5SZWFkLkFsbCBBY2Nlc3NSZXZpZXcuUmVhZFdyaXRl
                          LkFsbCBBZ3JlZW1lbnQuUmVhZC5BbGwgQWdyZWVtZW50LlJlYWRXcml0ZS5BbGwgQWdyZWVtZW50QWNjZXB0YW5jZS5SZWFkIEFncmVlbWVudEFjY2VwdGFuY2UuUmVhZC5BbGwgQWxsU2l0ZXMuUmVhZCBBcHBDYXRhbG9nL
                          lJlYWRXcml0ZS5BbGwgQXVkaXRMb2cuUmVhZC5BbGwgQm9va2luZ3MuTWFuYWdlLkFsbCBCb29raW5ncy5SZWFkLkFsbCBCb29raW5ncy5SZWFkV3JpdGUuQWxsIEJvb2tpbmdzQXBwb2ludG1lbnQuUmVhZFdyaXRlLkFsbC
                          BDYWxlbmRhcnMuUmVhZCBDYWxlbmRhcnMuUmVhZC5BbGwgQ2FsZW5kYXJzLlJlYWQuU2hhcmVkIENhbGVuZGFycy5SZWFkV3JpdGUgQ2FsZW5kYXJzLlJlYWRXcml0ZS5BbGwgQ2FsZW5kYXJzLlJlYWRXcml0ZS5TaGFyZWQ
                          gQ29udGFjdHMuUmVhZCBDb250YWN0cy5SZWFkLkFsbCBDb250YWN0cy5SZWFkLlNoYXJlZCBDb250YWN0cy5SZWFkV3JpdGUgQ29udGFjdHMuUmVhZFdyaXRlLkFsbCBDb250YWN0cy5SZWFkV3JpdGUuU2hhcmVkIERldmlj
                          ZS5Db21tYW5kIERldmljZS5SZWFkIERldmljZU1hbmFnZW1lbnRBcHBzLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRBcHBzLlJlYWRXcml0ZS5BbGwgRGV2aWNlTWFuYWdlbWVudENvbmZpZ3VyYXRpb24uUmVhZC5BbGwgR
                          GV2aWNlTWFuYWdlbWVudENvbmZpZ3VyYXRpb24uUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50TWFuYWdlZERldmljZXMuUHJpdmlsZWdlZE9wZXJhdGlvbnMuQWxsIERldmljZU1hbmFnZW1lbnRNYW5hZ2VkRGV2aW
                          Nlcy5SZWFkLkFsbCBEZXZpY2VNYW5hZ2VtZW50TWFuYWdlZERldmljZXMuUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkLkFsbCBEZXZpY2VNYW5hZ2VtZW50UkJBQy5SZWFkV3JpdGUuQWxsIERldml
                          jZU1hbmFnZW1lbnRTZXJ2aWNlQ29uZmlnLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRTZXJ2aWNlQ29uZmlnLlJlYWRXcml0ZS5BbGwgRGlyZWN0b3J5LkFjY2Vzc0FzVXNlci5BbGwgRGlyZWN0b3J5LlJlYWQuQWxsIERp
                          cmVjdG9yeS5SZWFkV3JpdGUuQWxsIEVBUy5BY2Nlc3NBc1VzZXIuQWxsIEVkdUFkbWluaXN0cmF0aW9uLlJlYWQgRWR1QWRtaW5pc3RyYXRpb24uUmVhZFdyaXRlIEVkdUFzc2lnbm1lbnRzLlJlYWQgRWR1QXNzaWdubWVud
                          HMuUmVhZEJhc2ljIEVkdUFzc2lnbm1lbnRzLlJlYWRXcml0ZSBFZHVBc3NpZ25tZW50cy5SZWFkV3JpdGVCYXNpYyBFZHVSb3N0ZXIuUmVhZCBFZHVSb3N0ZXIuUmVhZEJhc2ljIEVkdVJvc3Rlci5SZWFkV3JpdGUgZW1haW
                          wgRXhjaGFuZ2UuTWFuYWdlIEZpbGVzLlJlYWQgRmlsZXMuUmVhZC5BbGwgRmlsZXMuUmVhZC5TZWxlY3RlZCBGaWxlcy5SZWFkV3JpdGUgRmlsZXMuUmVhZFdyaXRlLkFsbCBGaWxlcy5SZWFkV3JpdGUuQXBwRm9sZGVyIEZ
                          pbGVzLlJlYWRXcml0ZS5TZWxlY3RlZCBGaW5hbmNpYWxzLlJlYWRXcml0ZS5BbGwgZnVsbF9hY2Nlc3NfYXNfdXNlciBHcm91cC5SZWFkLkFsbCBHcm91cC5SZWFkV3JpdGUuQWxsIElkZW50aXR5UHJvdmlkZXIuUmVhZC5B
                          bGwgSWRlbnRpdHlQcm92aWRlci5SZWFkV3JpdGUuQWxsIElkZW50aXR5Umlza0V2ZW50LlJlYWQuQWxsIGlkZW50aXR5cmlza3l1c2VyLnJlYWQuYWxsIE1haWwuUmVhZCBNYWlsLlJlYWQuQWxsIE1haWwuUmVhZC5TaGFyZ
                          WQgTWFpbC5SZWFkV3JpdGUgTWFpbC5SZWFkV3JpdGUuQWxsIE1haWwuUmVhZFdyaXRlLlNoYXJlZCBNYWlsLlNlbmQgTWFpbC5TZW5kLkFsbCBNYWlsLlNlbmQuU2hhcmVkIE1haWxib3hTZXR0aW5ncy5SZWFkIE1haWxib3
                          hTZXR0aW5ncy5SZWFkV3JpdGUgTWVtYmVyLlJlYWQuSGlkZGVuIE5vdGVzLkNyZWF0ZSBOb3Rlcy5SZWFkIE5vdGVzLlJlYWQuQWxsIE5vdGVzLlJlYWRXcml0ZSBOb3Rlcy5SZWFkV3JpdGUuQWxsIE5vdGVzLlJlYWRXcml
                          0ZS5DcmVhdGVkQnlBcHAgTm90aWZpY2F0aW9ucy5SZWFkV3JpdGUuQ3JlYXRlZEJ5QXBwIG9mZmxpbmVfYWNjZXNzIG9wZW5pZCBQZW9wbGUuUmVhZCBQZW9wbGUuUmVhZC5BbGwgUGVvcGxlLlJlYWRXcml0ZSBQb2xpY3ku
                          UmVhZC5BbGwgUG9saWN5LlJlYWRXcml0ZS5Db25kaXRpb25hbEFjY2VzcyBQcml2aWxlZ2VkQWNjZXNzLlJlYWRXcml0ZS5BenVyZUFEIFByaXZpbGVnZWRBY2Nlc3MuUmVhZFdyaXRlLkF6dXJlUmVzb3VyY2VzIHByb2Zpb
                          GUgUHJvZ3JhbUNvbnRyb2wuUmVhZC5BbGwgUHJvZ3JhbUNvbnRyb2wuUmVhZFdyaXRlLkFsbCBSZXBvcnRzLlJlYWQuQWxsIFNlY3VyaXR5RXZlbnRzLlJlYWQuQWxsIFNlY3VyaXR5RXZlbnRzLlJlYWRXcml0ZS5BbGwgU2
                          l0ZXMuRnVsbENvbnRyb2wuQWxsIFNpdGVzLk1hbmFnZS5BbGwgU2l0ZXMuUmVhZC5BbGwgU2l0ZXMuUmVhZFdyaXRlLkFsbCBTdWJzY3JpcHRpb24uUmVhZC5BbGwgVGFza3MuUmVhZCBUYXNrcy5SZWFkLlNoYXJlZCBUYXN
                          rcy5SZWFkV3JpdGUgVGFza3MuUmVhZFdyaXRlLlNoYXJlZCBVc2VyLkV4cG9ydC5BbGwgVXNlci5JbnZpdGUuQWxsIFVzZXIuUmVhZCBVc2VyLlJlYWQuQWxsIFVzZXIuUmVhZEJhc2ljLkFsbCBVc2VyLlJlYWRXcml0ZSBV
                          c2VyLlJlYWRXcml0ZS5BbGwgVXNlckFjdGl2aXR5LlJlYWRXcml0ZS5DcmVhdGVkQnlBcHAgVXNlclRpbWVsaW5lQWN0aXZpdHkuV3JpdGUuQ3JlYXRlZEJ5QXBwIiwic2lnbmluX3N0YXRlIjpbImttc2kiXSwic3ViIjoiN
                          zNyZzI3OEFBVG1uU0ZNS05XMUhJYTduZXduNG5UWUdsYVo1S3Y2cVlxUSIsInRpZCI6ImIxODc1Y2Q4LWEzOWItNDFjNy1hNGE4LTYwMWY0M2M1YTIxMiIsInVuaXF1ZV9uYW1lIjoiZG9wQGF2aWFuLmRrIiwidXBuIjoiZG
                          9wQGF2aWFuLmRrIiwidXRpIjoiUWU0elFodGdkVVdMVVV6UHpvZExBQSIsInZlciI6IjEuMCIsIndpZHMiOlsiNjJlOTAzOTQtNjlmNS00MjM3LTkxOTAtMDEyMTc3MTQ1ZTEwIl0sInhtc190Y2R0IjoxNTA3MTg5ODcyfQ.
                          IvwD1ow-aHTE_OIyiCk7QFmRUAbPY6WaFBdyXouiG7fu8WJxmtgIp2D2yzyzA3P5fAs34PPH7tNcsyOJBWQlUSbTXjML_T5X_Y8xiC0sJlXK5RpQ1ftCicLyo4MuCp7Z5Yx7V7Q3yLZ5hIYuAMBa_jbAzBqM9tOnqR8pa56fx
                          DLanqqikJVJ5cpEemZRc4QyY2B9shbIpxlu9r5kokkbzkDguaPT-jrPtLivlKr8MuCZ11ToDHTdjqj78S6mjR7PoWV649knPoBoVUzSdvUzxHi6XskwyYheQtmQQsF6Q0T_1lntsbbPoogDaFi-xH83KwVn7INhpGUkl0GQUw
                          -BMw
                            Content-Type: application/json; charset=utf-8
                            Content-Length: 26
                          }
    IsSuccessStatusCode : False



    Monday, November 19, 2018 2:13 PM

All replies

  • Looks to me it didn't find the email and the error your getting is because your trying make a get request to with null MessageId you should put a null check eg

     $Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId 
       If($Item){
           Set-EXRItemCategory -MailboxName $MailboxName -Item $Item -Categories @("red")
    }else{
      Write-host "Message not found"
    }
    
    
    

    The other problems is your csv isn't formatted correctly (you have semi column separating the columns) and also the messageId  wouldn't work because your missing the enclosing <> character on the messageId which means that isn't complete and that code does and eq filter so would find that anyway eg a valid request would be

    $Item = Find-EXRMessageFromMessageId -MessageId "<DM5PR2101MB086906298DF88E4D39CBA
    7D4D9D80@DM5PR2101MB0869.namprd21.prod.outlook.com>"

    Cheers
    Glen

    Monday, November 19, 2018 10:45 PM
  • Thanks Glen.

    Hi Obbi,

    Have you checked this as Glen mentioned ? If you have any question, or update, please feel free to let me know.

    Regards,

    Simon 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, November 20, 2018 11:01 AM
  • Looks to me it didn't find the email and the error your getting is because your trying make a get request to with null MessageId you should put a null check eg

     $Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId 
       If($Item){
           Set-EXRItemCategory -MailboxName $MailboxName -Item $Item -Categories @("red")
    }else{
      Write-host "Message not found"
    }
    
    

    The other problems is your csv isn't formatted correctly (you have semi column separating the columns) and also the messageId  wouldn't work because your missing the enclosing <> character on the messageId which means that isn't complete and that code does and eq filter so would find that anyway eg a valid request would be

    $Item = Find-EXRMessageFromMessageId -MessageId "<DM5PR2101MB086906298DF88E4D39CBA
    7D4D9D80@DM5PR2101MB0869.namprd21.prod.outlook.com>"

    Cheers
    Glen

    Thanks Glen, i got it working after the "<>" !
    Tuesday, November 20, 2018 12:05 PM
  • Hi Obbi,

    This thread has been around for a long time. Please remember to mark the replies as answers if they helped. Please help us close the thread. Thanks for your understanding. I wish you a happy life!

    Regards,

    Simon


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Thursday, December 6, 2018 11:01 AM