PowerTip: Read a JSON configuration file as a PowerShell object

Doctor Scripto

Dr Scripto

Summary: Using the ConvertFrom-Json Cmdlet in PowerShell to read a JSON formatted file

A picture containing scissors  Description automatically generated

Hey, Doctor Scripto! I’ve seen a lot of JSON files in use in Azure. I’m not very good with editing JSON properly. Is there an easy way to read this and at least edit it with PowerShell?

Most definitely my good friend. For the file below called “settings.json” you can convert it to a PowerShell Object for editing purposes using the following line.   Once you have completed this, you can manipulate it like any other PowerShell Object.

$PowerShellObject=Get-Content -Path settings.json | ConvertFrom-Json

PowerShell, Doctor Scripto, Sean Kearney, PowerTip, JSON

 

Doctor Scripto
Dr Scripto

Scripter, PowerShell, vbScript, BAT, CMD

Follow Dr Scripto   

0 comments

    Leave a comment