I'm executing a program that is returning data in this format to the window:
Name : Computername
ID : number
Host Name : Hostname
Added : date
Online : True
Uptime : 3 hours
Boot Time : time
Current User : user
IP Address : ip
MAC Address : mac
Time Zone : Eastern Standard Time
Operating System
Name : Microsoft Windows 11 Enterprise Insider Preview
Version : 10.0.22463.1000
SP / Release : Dev
Installed : time
Serial Numbe : serial
System Drive : C
PowerShell Version: 5.1.22463.1000
IE Version : 11.1000.22463.0
Architecture : 64-bit
.NET Versions : 2.0 SP 2, 3.0 SP 2, 3.5 SP 1, 4.0 Client, 4.0 Full, 4.8 (or later)
Active Directory
Path : AD path
Description : desc
Domain : domain
Created : data
System
Manufacturer : Dell Inc.
Model : model
Memory : 32 GB
Serial Number : serial
BIOS Version : version
BIOS Manufacturer : Dell Inc.
BIOS Asset Tag : 00000000
When I get the type it is:
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
I can parse by array like:
$computerdata[0]
But it that would return:
Name : Computername
It stores each line in the array.
If I use:
$computerdata | ConvertTo-Json
I get:
[
"Name : Computername",
"ID : number",
"Host Name : hostname",
"Added : date",
"Online : True",
"Uptime : 3 hours",
"Boot Time : time",
"Current User : user",
"IP Address : ip",
"MAC Address : mac",
"Time Zone : Eastern Standard Time",
"",
"Operating System",
"Name : Microsoft Windows 11 Enterprise Insider Preview",
"Version : 10.0.22463.1000",
"SP / Release : Dev",
"Installed : time",
"Serial Numbe : serial",
"System Drive : C",
"PowerShell Version: 5.1.22463.1000",
"IE Version : 11.1000.22463.0",
"Architecture : 64-bit",
".NET Versions : 2.0 SP 2, 3.0 SP 2, 3.5 SP 1, 4.0 Client, 4.0 Full, 4.8 (or later)",
"",
"Active Directory",
"Path : AD path,
"Description : desc",
"Domain : domain",
"Created : data",
"",
"System",
"Manufacturer : Dell Inc.",
"Model : model",
"Memory : 32 GB",
"Serial Number : serial",
"BIOS Version : version",
"BIOS Manufacturer : Dell Inc.",
"BIOS Asset Tag : 00000000"
]
From there I wasn't sure where to go because I can see that I'd still be grabbing the whole line.
How do you parse through this format of data or convert to a better formatted json?