I am executing:
systeminfo | ConvertTo-Json
"Host Name: namehere",
"OS Name: Microsoft Windows 10 Enterprise",
...
but I need
"Host Name": "namehere",
"OS Name": "Microsoft Windows 10 Enterprise",
...
The following command gives a similar issue
systeminfo | ConvertTo-Xml -As String
<?xml version="1.0" encoding="utf-8"?>
<Objects>
<Object Type="System.String"></Object>
<Object Type="System.String">Host Name: namehere</Object>
<Object Type="System.String">OS Name: Microsoft Windows 10 Enterprise</Object> "
but I need something like:
<?xml version="1.0" encoding="utf-8"?>
<HostName>namehere</HostName>
<OSName>Microsoft Windows 10 Enterprise</OSName>
...
try this:
systeminfo /fo CSV | ConvertFrom-Csv
or
systeminfo /fo CSV | ConvertFrom-Csv | convertto-json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With