title: Different data types for same query between power shell versions
body: <p>I need to write script to iterate through all drives available in system and then do something with those drives. The code need to support PS versions 2.0 – 4.0. Problem is that when I retrieve list of drives, it comes back with different types between PS version 2.0 and 4.0 as shown below.</p>
  
  <pre><code>$PSVersionTable
  $drives = Get-WmiObject -class Win32_LogicalDisk -Filter "DriveType=3" | select   Name  
  'Type = ' + $drives.GetType().FullName
  Foreach($drive in $drives)
  {
      #some logic
  }
  </code></pre>
  
  <p>Here is output in PS version 2.0</p>
  
  <blockquote>
    <p>Name                           Value                                  </p>
    
    <p>----                           -----                                                                                                                                                                                                          CLRVersion                     2.0.50727.5485<br>
    BuildVersion                   6.1.7601.17514<br>
    PSVersion                      2.0<br>
    WSManStackVersion              2.0<br>
    PSCompatibleVersions           {1.0, 2.0}<br>
    SerializationVersion           1.1.0.1<br>
    PSRemotingProtocolVersion      2.1<br>
    Type is <strong>System.Management.Automation.PSCustomObject</strong></p>
  </blockquote>
  
  <p>This is what I get in PS version 3.0 and above.</p>
  
  <blockquote>
    <p>Name                           Value<br>
    ----                           -----                                                                                                                                                                                                          PSVersion                      4.0<br>
    WSManStackVersion              3.0<br>
    SerializationVersion           1.1.0.1<br>
    CLRVersion                     4.0.30319.42000<br>
    BuildVersion                   6.3.9600.16394<br>
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}<br>
    PSRemotingProtocolVersion      2.2<br>
    Type is <strong>System.Object[]</strong></p>
  </blockquote>
  
  <p>How can I make PS version 2.0 to also return an object[] so that my code could be consistent</p>