title: ActiveBatch ExecutePowerShellScript convert byte array to string
body: <p>I'm trying to use the ActiveBatch <strong>ExecutePowerShellScript</strong> job step to convert a <code>System.Byte[]</code> to a string.  The ActiveBatch job step has a property to specify the <code>InputObjects</code>, which I set to the output of the previous job step (this is just a field in the job steps editor, not PowerShell code). Then you apparently have access to a variable called <code>$input</code> in the PowerShell script..</p>
  
  <p>With just <code>$input</code> I get a list of bytes converted to integers.  With <code>$input | gm</code> I get:</p>
  
  <pre><code>There are 25 output objects generated by the Powershell script
  
     TypeName: System.Byte[]
  
  Name           MemberType    Definition                                         
  ----           ----------    ----------                                         
  Count          AliasProperty Count = Length     
  Address        Method        System.Byte&amp;, mscorlib, Version=2.0.0.0, Culture...
  </code></pre>
  
  <p>If I try <code>[System.Text.Encoding]::Unicode.GetString($input)</code> I get:</p>
  
  <blockquote>
    <p>Exception taken executing PowerShell script: Cannot find an overload
    for "GetString" and the argument count: "1".</p>
  </blockquote>
  
  <p>If I try <code>[System.Text.Encoding]::Unicode.GetString(,$input)</code> I get:</p>
  
  <blockquote>
    <p>Exception taken executing PowerShell script: Missing ')' in method
    call.</p>
  </blockquote>
  
  <p>If I try:</p>
  
  <pre><code>[byte[]]$bytes = $input
  [System.Text.Encoding]::Unicode.GetString($bytes)
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>Exception taken executing PowerShell script: Cannot convert the
    "System.Management.Automation.Runspaces.PipelineReader<code>1+&lt;GetReadEnumerator&gt;d__0[System.Object]"
    value of type
    "System.Management.Automation.Runspaces.PipelineReader</code>1+d__0[[System.Object,
    mscorlib, Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089]]" to type "System.Byte[]".</p>
  </blockquote>
  
  <p>Any ideas?</p>