且构网

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

PowerShell 是否支持 HashTable 序列化?

更新时间:2023-11-05 13:26:28

当然,您可以使用 PowerShell 的 本机 CliXml 格式:

Sure, you can use PowerShell's native CliXml format:

@{
  a = 1
  b = [pscustomobject]@{
    prop = "value"
  }
} | Export-Clixml -Path hashtable.ps1xml

使用 Import- 反序列化CliXml:

PS C:> $ht = Import-CliXml hashtable.ps1xml
PS C:> $ht['b'].prop -eq 'value'
True