title: Cannot convert result form Invoke-Command to csv type
body: <p>I have a problem with converting results from <code>Invoke-Command</code> into csv type. Code below :</p>
  
  <pre><code>    $remoteResultEventLog += Invoke-Command -ScriptBlock {
  Param ( [string]$EventLogName,
          [string]$EventLogEntryType,
          [DateTime]$EventLogAfter, 
          [DateTime]$EventLogBefore, 
          [string] $searchPattern, 
          [Boolean] $caseSensitive)
  
      $events = Get-EventLog -LogName $EventLogName -EntryType $EventLogEntryType -After $EventLogAfter -Before $EventLogBefore
      if ( $caseSensitive ) 
      { 
          $events | Select-Object Index, Time, EntryType, Source, InstanceID, Message, PSComputerName, @{Name='Search Pattern';Expression={$searchPattern}} `
          | Where-Object { Select-String -InputObject $_.message -Pattern $searchPattern -Quiet -CaseSensitive}
      }
      else 
      { 
          $events | Select-Object Index, Time, EntryType, Source, InstanceID, Message, PSComputerName, @{Name='Search Pattern';Expression={$searchPattern}} `
          | Where-Object { Select-String -InputObject $_.message -Pattern $searchPattern -Quiet }
      } 
      } -ArgumentList $EventLogName, $EventLogEntryType, $EventLogAfter, $EventLogBefore, $searchPattern, $caseSensitive -Session $serverSession
  
      $remoteResultEventLogCsv = $remoteResultEventLog | ConvertTo-Csv -NoTypeInformation -Delimiter ";"
  </code></pre>
  
  <p>The last line give this error :</p>
  
  <pre><code>ConvertTo-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
  
  At C:\Temp\RemoteCheckTest\new\RemoteCheckFiles.ps1:131 char:65
  
  + $remoteResultEventLogCsv = $remoteResultEventLog | ConvertTo-Csv &lt;&lt;&lt;&lt;  -NoTypeInformation -Delimiter ";"
  
      + CategoryInfo          : InvalidData: (:) [ConvertTo-Csv], ParameterBindingValidationException
  
      + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToCsvCommand
  </code></pre>
  
  <p>But Input Object in that case <code>$remoteResultEventLog</code> is not a null I checked</p>
  
  <p>Thanks for any answer</p>