title: Powershell to Json file
body: <p>i'm trying to get a list of all devices with yellow bang on a given platform, write it as a dictionary to json file, and finally read it via python script.</p>
  
  <p>All seems pretty easy, i can save the string to json file but when i try to open it i get an error.
  i can't figure out if the problem is with the powershell script, or maybe i'm just not constructing the json object correctly.</p>
  
  <pre><code>$baddevices = Get-WmiObject Win32_PNPEntity | where {$_.ConfigManagerErrorcode -ne 0}
  
  $jsonRepresentation = '{'
  
  foreach ($device in $baddevices) {
      $jsonRepresentation = $jsonRepresentation + " {0}: {1}," -f $device.name, $device.deviceid 
  }
  
  
  $jsonRepresentation = $jsonRepresentation.Substring(0,$jsonRepresentation.Length-1) + '}'
  
  
  $jsonRepresentation | ConvertTo-Json | Out-File "C:\file.json"
  </code></pre>