PowerShell 是否支持 HashTable 序列化? [英] Does PowerShell support HashTable Serialization?

查看:15
本文介绍了PowerShell 是否支持 HashTable 序列化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想将一个对象/HashTable 写入磁盘并稍后再次加载它,PowerShell 支持吗?

If I want to write an object / HashTable to disk and load it up again later does PowerShell support that?

推荐答案

当然,您可以使用 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

这篇关于PowerShell 是否支持 HashTable 序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆