如果使用powershell的键中有破折号(-),如何读取json中的值

如果使用powershell的键中有破折号(-),如何读取json中的值,json,powershell,Json,Powershell,考虑到这一点: { “StudentInfo":{ “first-name": “xyz", “Student_id": "123-xyz" } } 我可以使用下面的代码读取student_id的值 $config = Get-Content -Raw $Config $configObject = ConvertFrom-Json –InputObject $config $StudentId = $configObject.StudentInfo.Student_id 但

考虑到这一点:

{
 “StudentInfo":{
   “first-name": “xyz",
   “Student_id": "123-xyz"
 }
}
我可以使用下面的代码读取student_id的值

$config = Get-Content -Raw $Config
$configObject = ConvertFrom-Json –InputObject $config
$StudentId = $configObject.StudentInfo.Student_id
但是,我无法读取“first name”的值,因为powershell将其视为命令而不是变量。更改键名不是我的选项

如何使用powershell 5.1检索“first name”的值?

使用引号:

$configObject.StudentInfo.'first-name'