title: How can I fix my csv that has nested json objects in each cell?
body: <p>My code works, but it exports data into json valued formats in a csv</p>
  <pre><code>Import-Module &quot;$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1&quot; @initParams
  # Site configuration
  $SiteCode = Get-PSDrive -PSProvider CMSITE
  $ProviderMachineName = &quot;machine_name&quot; # SMS Provider machine name
  Set-Location &quot;$($SiteCode.Name):\&quot;
  
  
  $WQL = @&quot;
  select SMS_R_System.NetbiosName, SMS_R_System.LastLogonUserName, SMS_R_System.OperatingSystemNameandVersion, SMS_G_System_BITLOCKER_DETAILS.DriveLetter, SMS_G_System_MBAM_POLICY.MBAMPolicyEnforced, SMS_G_System_BITLOCKER_DETAILS.EncryptionMethod, SMS_G_System_MBAM_POLICY.MBAMPolicyEnforced from SMS_R_System inner join SMS_G_System_MBAM_POLICY on SMS_G_System_MBAM_POLICY.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_BITLOCKER_DETAILS on SMS_G_System_BITLOCKER_DETAILS.ResourceID = SMS_R_System.ResourceId where SMS_G_System_BITLOCKER_DETAILS.DriveLetter = &quot;C:&quot; or SMS_G_System_BITLOCKER_DETAILS.DriveLetter = &quot;D:&quot;
  &quot;@
  $collectionID = 'CDT003DO'
  Invoke-CMWmiQuery -Query $WQL | Export-CSV C:\Test\output1
  </code></pre>
  <p>the output looks like the below csv, do I need to use a pscustomobject of some sort? I would like to &quot;flatten&quot; everything so information is all in one line</p>
  <p><a href="https://i.stack.imgur.com/9LKTz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9LKTz.png" alt="enter image description here" /></a></p>
  <p>or is there a better way to export the information from SCCM? I am trying to do it in powershell so that I can create a scheduled task and have it print out the information daily</p>