title: Powershell echo vs write-host and different outputs
body: <p>I am trying to write my first script but am having some issues with powershell.</p>
  
  <p>I am using the following code:</p>
  
  <pre><code>$Disk = Get-Disk | Where-Object {$_.Path -match "USBSTOR" -and $_.Size -gt 20Gb -and $_.Size -lt 200Gb -and -not $_.IsBoot }
  </code></pre>
  
  <p>I can't figure out why </p>
  
  <pre><code>PS C:\&gt; echo $disk
  Number Friendly Name                            OperationalStatus                    Total Size Partition Style
   ------ -------------                            -----------------                    ---------- ---------------
  1      Imation IronKey Wkspace USB Device       Online                                 59.63 GB MBR
  </code></pre>
  
  <p>and </p>
  
  <pre><code>PS C:\&gt; write-host $disk
  MSFT_Disk (ObjectId = "\\?\usbstor#disk&amp;ven_imation&amp;prod_ironk...)
  </code></pre>
  
  <p>It is more complicated by the following powershell script:</p>
  
  <pre><code>$Disk = Get-Disk | Where-Object {$_.Path -match "USBSTOR" -and $_.Size -gt 20Gb -and $_.Size -lt 200Gb -and -not $_.IsBoot }
  $WIM = Get-PSDrive -PSProvider FileSystem | Where { Test-Path (join-path $_.Root "\sources\install.wim") }
  echo $Disk
  echo $WIM
  Write-Host $WIM
  Write-Host $Disk
  </code></pre>
  
  <p>and then change the order of the echo's and writes I get different outputs</p>
  
  <p>can someone explain what is going on?</p>