- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert JSON to CSV file using PowerShell?
To convert the JSON to the CSV format we need to first use the ConvertFrom-JSON command. For example, we have already JSON file present with us at the C:\temp\VMinfo.JSON location. We will first import this file and then convert it to CSV as shown below.
Get-Content C:\Temp\VMInfo.json | ConvertFrom-Json | Export-Csv C:\Temp\vminfo.csv -NoTypeInformation
Suppose you have cmdlet that produces output in the hash table format as shown below.
PS C:\> Get-AzVM -VMName TestMachine2k16 | Select -ExpandProperty Tags Key Value --- ----- For Ansible Patching_Day Sunday Application SecretTag Owner Chirag
So we first need to convert the hash output to the JSON format and then from the JSON, we can save the output to excel.
PS C:\> Get-AzVM -VMName TestMachine2k16 | Select -ExpandProperty Tags | ConvertTo-Json | ConvertFrom-Json | Export-Csv C:\temp\Vmtags.csv -NoTypeIn formation
- Related Articles
- How to convert JSON file to CSV file using PowerShell?
- How to edit the CSV file using PowerShell?
- How to retrieve CSV file headers using PowerShell?
- How to append data into a CSV file using PowerShell?
- How to convert JSON object to Hashtable format using PowerShell?
- How to convert the hashtable to the JSON format using PowerShell?
- How to create a CSV file manually in PowerShell?
- How to convert a JSON array to CSV in Java?
- Convert CSV to JSON using the Jackson library in Java?\n
- How to Export and import CSV file manually in PowerShell?
- Importing / Exporting CSV file in PowerShell
- How to parse a CSV file using PHP
- Write a Python code to read JSON data from a file and convert it to dataframe, CSV files
- How to convert raw text to the CSV (Comma Separated Values) in PowerShell?
- How to create dynamic columns (headers) in CSV using PowerShell?