title: Forcing single result as array in JSON output
body: <p>I am retrieving inventory data from a SQL database, this i want to be transformed into JSON for further processing.</p>
  
  <p>There are separate queries for Operating System, Processors and Applications (Add&amp;Remove Information). </p>
  
  <p>For the OS usually one row is returned, for processors there is either one or more lines, and for applications there is usually a couple lines. </p>
  
  <p>Retrieval of data is done like this (this part works fine):</p>
  
  <pre><code>$deviceOperatingSystem = Invoke-Sqlcmd -ServerInstance $sqlServer -Database $sqlDatabase -Query $inventoryOperatingSystemQuery -credential $databaseCredentials -Variable $variables
  $deviceProcessors = Invoke-Sqlcmd -ServerInstance $sqlServer -Database $sqlDatabase -Query $inventoryProcessorsQuery -credential $databaseCredentials -Variable $variables
  $deviceApplications = Invoke-Sqlcmd -ServerInstance $sqlServer -Database $sqlDatabase -Query $inventoryApplicationsQuery -credential $databaseCredentials -Variable $variables
  </code></pre>
  
  <p>it is then fed to an array like this: </p>
  
  <pre><code>$deviceInventoryOutput = @()
      $deviceInventoryOutput += [PSCustomObject]@{
          'OperatingSystem'    = $deviceOperatingSystem
          'Processors'         = $deviceProcessors     
          'Applications'       = $deviceApplications   
                      }
  </code></pre>
  
  <p>and the output looks like this: </p>
  
  <pre><code>{
      "OperatingSystem":  {
                              "Caption":  "Microsoft Windows 10 Enterprise",
                              "Version":  "10.0.16299",
                              "BuildNumber":  "16299",
                              "ServicePackMajorVersion":  0,
                              "Language":  1031
                          },
      "Processors":  {
                         "Name":  "Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz",
                         "Description":  "Intel64 Family 6 Model 78 Stepping 3",
                         "Manufacturer":  "GenuineIntel",
                         "NumberOfCores":  1,
                         "NumberOfLogicalCores":  1
                     },
      "Applications":  [
                           {
                               "Name":  "IM.order",
                               "Publisher":  "Ingram Micro Distribution GmbH",
                               "Version":  "6.41.761.0"
                           },
                           {
                               "Name":  "JTL-Wawi",
                               "Publisher":  "JTL-Software-GmbH",
                               "Version":  "1.2.3.7"
                           },...
  }
  </code></pre>
  
  <p>the receiving API expects the information for processors as an array, even if there is only one entry, so my example should actually look like this:</p>
  
  <pre><code>{
      "Processors":  [{
                         "Name":  "Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz",
                         "Description":  "Intel64 Family 6 Model 78 Stepping 3",
                         "Manufacturer":  "GenuineIntel",
                         "NumberOfCores":  1,
                         "NumberOfLogicalCores":  1
                     }]
  }
  </code></pre>
  
  <p>i tried to wrap the processors variable like this</p>
  
  <pre><code>'Processors'         = @($deviceProcessors)
  </code></pre>
  
  <p>but this didn't help much.i also tried initializing the $deviceProcessors as an array like: </p>
  
  <pre><code>$deviceProcessors = @()
  $deviceProcessors += Invoke-Sqlcmd -ServerInstance $sqlServer -Database $sqlDatabase -Query $inventoryProcessorsQuery -credential $databaseCredentials -Variable $variables
  </code></pre>
  
  <p>but also, nope didn't work out.</p>
  
  <pre><code> $deviceProcessors.GetType() returns System.Data.DataRow
   $deviceApplications.GetType() returns System.Object[]
  </code></pre>
  
  <p>The expected output should have [] around the information for the processors if only one result is returned from the query.</p>