title: op_Division and Data Types in powershell
body: <p>Hi I am having a problem with some powershell I am using to detect screen resolution and then divide width by height.</p>
  
  <pre><code>$width = (Get-WmiObject -Class Win32_VideoController).CurrentHorizontalResolution
  $height = (Get-WmiObject -Class Win32_VideoController).CurrentVerticalResolution
  $result = $width / $height
  echo $width
  echo $height
  echo $result
  </code></pre>
  
  <p>Basically the problem is with the third line above. I get an error along the lines of this in the PS console.</p>
  
  <pre><code>Method invocation failed because [System.Object[]] does not contain a method named 'op_Division'.
  </code></pre>
  
  <p>I kind of understand what's going on here. The variables $width and $height aren't in the correct type e.g. decimal or double. The problem is I have no idea how to assign this type to these variables. I have tried the following.</p>
  
  <pre><code>[double]$width = (Get-WmiObject -Class Win32_VideoController).CurrentHorizontalResolution
  [double]$height = (Get-WmiObject -Class Win32_VideoController).CurrentVerticalResolution
  [double]$result = $width / $height
  echo $width
  echo $height
  echo $result
  </code></pre>
  
  <p>The problem is that I get this error in the PS console.</p>
  
  <pre><code>Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Double".
  </code></pre>
  
  <p>So basically it can't convert the $width and $height variables to the type I need to be able to divide the resulting numbers which it seems are of type System.Object[].</p>
  
  <p>Can anyone please point me in the right direction? I am fairly new to powershell so am learning as I go I think anything I learn from this will be incredibly useful in my journey to becoming a fluent powersheller. Any help is also greatly appreciated.</p>
  
  <p>PS - this seemed to work on Windows 7 running powershell 4.0 but I am using my home PC now which is Windows 8.1 running powershell 4.0</p>