I have a json file which has some information in as:-
$json.Hardware.'Network Adapters'.'Network Adapter 1'.'MAC Address'
$json.Hardware.'Network Adapters'.'Network Adapter 2'.'MAC Address'
$json.Hardware.'Network Adapters'.'Network Adapter 3'.'MAC Address'
$json.Hardware.'Network Adapters'.'Network Adapter 4'.'MAC Address'
$json.Hardware.'Network Adapters'.'Network Adapter 5'.'MAC Address'
Select all Open in new window
I need to pull out the information, so thought about using a for loop:-
for ($x=1; $x -le 10; $x++) {
if ($json.Hardware.'Network Adapters'.'Network Adapter $x'.Type -contains 'Wired*') {
Write-Host "MAC Wired - " $json.Hardware.'Network Adapters'.'Network Adapter $x'.'MAC Address'
}
}
Select all Open in new window
But it isnt working. Im assuming Im not concatinating the $x in the variable name correctly, but tried to put it outside the loop as a variable, but that doesnt work.
Any ideas?