Exchange Online Powershell - JSON Error

MS 0 Reputation points
2023-01-11T07:26:22.9766667+00:00

Hi all,

I'm currently attempting to extract Auditlog records via Powershell, however I'm regularly getting errors in relation to a JSON conversion error. I am using a slightly modified version of this script. The small changes relate to date periods, and an addition of a User variable. I'm currently running EXO v3.0.0 too. The error found in the Powershell window along with the error within the cmdlet log can be found below.

Powershell window error

ConvertFrom-Json : Invalid JSON primitive: .
At C:\Users\...\AppData\Local\Temp\tmpEXO_0q1mvkwr.0ub\tmpEXO_0q1mvkwr.0ub.psm1:576 char:35
+ ... etailsToPSObject = ConvertFrom-Json $ErrorObject.ErrorDetails.Message
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

cmdlet Error Log message

Invalid JSON primitive: .-   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()	   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)	   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input  Int32 depthLimit  JavaScriptSerializer serializer)	   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer  String input  Type type  Int32 depthLimit)	   at Microsoft.PowerShell.Commands.JsonObject.ConvertFromJson(String input  ErrorRecord& error)	   at Microsoft.PowerShell.Commands.ConvertFromJsonCommand.ConvertFromJsonHelper(String input)	   at System.Management.Automation.CommandProcessorBase.Complete();

I'm assuming the error relates to the EXO module itself, but I'm unsure.

Microsoft Exchange Online
{count} votes

1 answer

Sort by: Most helpful
  1. Aholic Liang-MSFT 13,821 Reputation points Microsoft Vendor
    2023-01-12T08:31:53.1966667+00:00

    Hi @MS ,

    How did you modify the parameters? Is there a double quote enclosing the values?

    In my tests, the script can be run successfully, you can refer to the following:

    2023-1-12-6

    (Note: The red box is the modification section.)


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread

    0 comments No comments