Often you may want to extract a specific value from a JSON file using PowerShell.
Here is an example of how to do so:
(Get-Content 'my_teams.json' | ConvertFrom-Json).Location
This particular example extracts the value from the Location property of the JSON file named my_teams.json.
Note that we use the Get-Content cmdlet to first extract the content from the JSON file.
We then use the ConvertFrom-Json cmdlet to convert the content to a readable format in PowerShell.
Lastly, we use a period followed by the specific name of the property ( “Location” ) whose value we’d like to extract from the file.
The following example shows how to uses this syntax in practice.
Example: How to Extract Value from JSON File Using PowerShell
Suppose that we have a JSON file named my_teams.json with information about various basketball teams.
We can use the Get-Content cmdlet to first view the contents of this file:
Get-Content 'my_teams.json'
The following screenshot shows how to use this syntax in practice:

Suppose that we would like to extract all values from the Location property in the file.
We can use the following syntax to do so:
(Get-Content 'my_teams.json' | ConvertFrom-Json).Location
The following screenshot shows how to use this syntax in practice:

Notice that this returns the values Dallas and Houston, which are the two values stored in the Location property of the file.
Note that we could also use brackets to extract a specific occurrence from the Location property.
For example, we could use the following syntax to only extract the first value that occurs in the Location property:
(Get-Content 'my_teams.json' | ConvertFrom-Json).Location[0]
The following screenshot shows how to use this syntax in practice:

Notice that this only returns Dallas, which represents the first value that occurs in a property named Location in the JSON file.
Note: You can find the complete documentation for the ConvertFrom-Json cmdlet in PowerShell here.
Related Tutorials
The following tutorials explain how to perform other common tasks in PowerShell:
PowerShell: How to Save JSON Object to a File
PowerShell: How to Edit a JSON File
PowerShell: How to Use ConvertTo-Json on Array with Single Item
