Quantcast
Channel: Scripting Blog
Viewing all articles
Browse latest Browse all 2129

PowerTip: Read a JSON configuration file as a PowerShell object

$
0
0

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

 

The post PowerTip: Read a JSON configuration file as a PowerShell object appeared first on Scripting Blog.


Viewing all articles
Browse latest Browse all 2129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>