title: Multiple commands in Powershell script with Export
body: <p>I've been trying to work through this for quite some time.  My ultimate goal is to get the exported report as a single csv sheet.  However, I've been highly unsuccessful.  I then broke it down to export 2 sheets that I can just merge, however, CIM is not playing nice with that at all.  Then my other issue came with not calling from my list properly.</p>
  
  <pre><code>$ComputerList = "C:\ps_test\pclastlogon.txt"
  $LogPath = "C:\ps_test\Logs"
  $LogTime = Get-Date -Format s | foreach {$_ -replace ":", "-"}
  $CsvLogonPath = $LogPath+'\RebootStatus-'+$LogTime+'-Logon.csv'
  $CsvBootPath = $LogPath+'\RebootStatus-'+$LogTime+'-LastBoot.csv'
  
  Import-Module ActiveDirectory
  
  IF ( -Not (Test-Path -Path $LogPath)) {New-Item -Path $LogPath -ItemType Directory}
  
  $Computers = Get-Content $ComputerList
  
  Foreach ($Computers in $ComputerList) {
  Get-ADComputer -Identity $Computers -Properties * -Filter * | Select-Object cn,LastLogonDate,@{LABEL="Last Logon";EXPRESSION={[DateTime]::FromFileTime($_.LastLogon)}} | Export-Csv -Path $CsvLogonPath
  }
  
  Foreach ($Computers in $ComputerList) {
  Get-CimInstance Win32_OperatingSystem -ComputerName $Computers | Select csname,LastBootUpTime | Export-Csv -Path $CsvBootPath
  }
  </code></pre>
  
  <p>Can someone please point me in the right direction?  Thanks in advance.</p>