Using convertfrom-json to search for records in json formatted file

hi out there

I am newbie to powershell and have always used shell or awk in linux to solve scripting - but now I want to get it done in powershell instead since this is my native working platform

I have a small problem here when I am trying to use converfrom-json to get the access to the different records in a json formatted string - ex:

$x = Get-content -path c:\temp\file.json | convertfrom-json
$x | ForEach-Object {

f ( $x.model -Match “MY” ) {
Write-Host $x.model, $x.publicip }

the records look f.ex like this:

mac : ac:17:c8:3b:e5:b0
networkId :
model : MY225
publicIp :

mac : ac:17:c8:3b:ec:78
networkId :
model : MS225
publicIp :

To print model and publicip - how should the script look just to give me some starting hints?

br tiwang

Using -match is a regex expression. To do a simple wildcard search, you can use -like.

$x = Get-content -path c:\temp\file.json | convertfrom-json
$x | Where-Object {$_.model -like '*my*'}