PowerShell是否支持哈希表序列化? [英] Does PowerShell support HashTable Serialization?
本文介绍了PowerShell是否支持哈希表序列化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我想将对象/哈希表写入磁盘并稍后再次加载,PowerShell是否支持?
If I want to write an object / HashTable to disk and load it up again later does PowerShell support that?
推荐答案
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是否支持哈希表序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文