title: Output text from PowerShell, read into Python
body: <p>I am trying to pull a variety of system metrics from a PowerShell Script into Python for further processing.  I have picked the data that I need and used echo to place it into a txt file which I am attempting to read with Python, but when I look at the Python data, I just get gibberish.  Does Powershell use some strange encoding when it outputs to txt files?  If so, is there a way to either get PowerShell to output in a format Python can read or instruct Python to read the format PowerShell uses?</p>
  
  <p>The PowerShell Code looks like this:</p>
  
  <pre class="lang-powershell prettyprint-override"><code>$Make = Get-CimInstance CIM_ComputerSystem | Select Manufacturer
  echo $Make.manufacturer &gt; c:\Mike\Output\SysConfig.txt
  $Model = Get-CimInstance CIM_ComputerSystem | Select Model
  echo $Model.model &gt;&gt; c:\Mike\Output\SysConfig.txt
  $Os = Get-CimInstance Win32_OperatingSystem | Select-Object  Caption
  echo $Os.caption &gt;&gt; c:\Mike\Output\SysConfig.txt
  $CPU = Get-WmiObject Win32_Processor | Select * 
  echo $CPU.Name &gt;&gt; c:\Mike\Output\SysConfig.txt
  echo $CPU.NumberOfCores &gt;&gt; c:\Mike\Output\SysConfig.txt
  echo $CPU.NumberOfLogicalProcessors &gt;&gt; c:\Mike\Output\SysConfig.txt
  echo $CPU.ThreadCount &gt;&gt; c:\Mike\Output\SysConfig.txt
  echo $CPU.MaxClockSpeed &gt;&gt; c:\Mike\Output\SysConfig.txt
  echo $CPU.CurrentClockSpeed &gt;&gt; c:\Mike\Output\SysConfig.txt
  </code></pre>
  
  <p>The text output looks like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>Hewlett-Packard
  HP EliteBook 2570p
  Microsoft Windows 10 Pro
  Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
  2
  4
  4
  2901
  2901
  </code></pre>
  
  <p>And the Python Code looks like this:</p>
  
  <pre><code>with open('c:\mike\output\SysConfig.txt', mode='r') as f:
      Manufacturer = f.readlines(1)
      Make = f.readlines(2)
      OS = f.readlines(3)
      CPU_Name = f.readlines(4)
      CPU_Phys_Cores = f.readlines(5)
      CPU_Log_Cores = f.readlines(6)
      CPU_Threads = f.readlines(7)
      CPU_Max_Clock = f.readlines(8)
      CPU_Curr_Clock = f.readlines(9)
  
  print(Manufacturer)
  print(Make)
  print(OS)
  print(CPU_Name)
  print(CPU_Phys_Cores)
  print(CPU_Log_Cores)
  print(CPU_Threads)
  print(CPU_Max_Clock)
  print(CPU_Curr_Clock)
  </code></pre>