title: How to pass json object as a parameter to another powershell script
body: <p>I am quite new to powershell stuff. So need some help here. </p>
  
  <p>I want to pass a json object as a parameter to another ps1. From what I read after searching is that I need to convert it to powershell object from json string. Please correct me if I am wrong. This is what I am doing </p>
  
  <p>Calling script:</p>
  
  <pre><code>$jsonParams = "{
       `"TaskName`": `"$taskName`",
        `"ExitCode`": `"$exitCode`",
        `"ErrorMessage`": `"$errorMessage`"
     }
  
  $jsonObject = $jsonParams | ConvertFrom-Json
  $argumentList = @($param1, $param2, $jsonObject) 
  
  Invoke-Expression "&amp; `"$scriptPath`" $argumentList"
  </code></pre>
  
  <p>and in called script - </p>
  
  <pre><code>param (
      [string]$param1,
      [string]$param2,
      [Microsoft.PowerShell.Commands.JsonObject]$jsonObject
  )
  </code></pre>
  
  <p>But, the calling script throws error</p>
  
  <pre><code>ConvertFrom-Json : Invalid object passed in, ':' or '}' expected. (21): {
  </code></pre>
  
  <p>What's wrong with this code. Also, after json object is passed to called script, how should I access its values in it.</p>
  
  <p>Thanks!!</p>