且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅当JSON属性存在时才排除它-Powershell

更新时间:2023-02-21 19:08:36

如果只想执行代码ifaddress具有member streets,则可以测试一下:

If you want to execute the code only if the address has the member streets you can test for just that:

if (
    ($FileContent.address | Get-Member -MemberType NoteProperty -Name "streets") -ne $null
){
    $FileContent.address = $FileContent.address | Select-Object * -ExcludeProperty streets
}