Trying to take a number of objects from a class using get-WmiObject. I have to return this as a hash-table/ dict type.
Command I'm using:
get-WmiObject -class win32_SoundDevice | select-object Name, Status
What I get:
Name Status
---- ------
Intel(R) Display Audio OK
Realtek Audio OK
I want to create something that looks like this:
[
{
"Name": "Intel(R) Display Audio",
"Status": "OK"
},
{
"Name": "Realtek Audio",
"Status": "OK"
}
]
I know I can append the | convertTo-json
command to the initial command, but I want to create the hash-table from scratch as I will be using it on legacy systems that may not have use of convertTo-json command.