title: Can I save result from invoke-restmethod as variable instead of an -outfile in powershell?
body: <p>I have a Invoke-Restmethod API script that creates a new mailinglist and returns the following </p>
  
  <pre><code>  Code Message                              Result
    ---- -------                              ------                             
    1    Mailing list successfully created    12345678
  </code></pre>
  
  <p>I need the result (ID for the new mailnglist) for the next operation.</p>
  
  <p>I know I can use -outfile to save the result to txt\xml\json and import it using get-contents, but it strikes me as more efficient and clean to just save the result in a variable without having to save an outfile and importing it back in. Is there a way to do this? </p>
  
  <p>My complete code:</p>
  
  <pre><code>Invoke-RestMethod $url -Method $method -Headers $headers -Body (ConvertTo-json $body) -ContentType "$outform"
  </code></pre>