title: Getting the value from python script into a powershell script
body: <p>I have python script which creates a ticket.
  I need to invoke the python script from within powershell script and
  get the ticketnumber(12 digit long).</p>
  <p>Approach#1:</p>
  <p>I tried to use the exit(ticket_number) to get this done.It worked well as long as the number is not very large.</p>
  <p>Ex.</p>
  <ul>
  <li>exit(12345) from python translates to $LASTEXITCODE=12345  #good</li>
  <li>exit(123456789123) from python translates to $LASTEXITCODE=-1 #not sure what is going wrong here</li>
  </ul>
  <pre><code>    dummy.py
      --------
      print(&quot;hello&quot;)
      exit(123456789123)
         
      sample.ps1
      ----------
      python dummy.py
      Write-Host($LASTEXITCODE)
  </code></pre>
  <p>Approach#2:</p>
  <p>Use of env variable</p>
  <pre><code>dummy.py
  --------
  import os
  os.environ[&quot;TICKETNUMBER&quot;] = &quot;123456789123&quot;
  exit(0)
  
  sample.ps1
  ----------
  Get-ChildItem -Path Env:TEMP # good - able to get value
  Get-ChildItem -Path Env:TICKETNUMBER # - error - ItemNotFoundException
  </code></pre>
  <p>So, I would like to know what is going wrong in each of the approaches.
  Are there any better approaches to get this done - Please suggest.</p>