以 PowerShell 对象表示法 (PSON) 保存哈希表 [英] Save hash table in PowerShell object notation (PSON)

查看:31
本文介绍了以 PowerShell 对象表示法 (PSON) 保存哈希表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题 从文件加载 PowerShell 哈希表? 文档如何将包含 PSON 格式的哈希表的文件加载到变量中,但如何将哈希表保存到 PSON 格式的文件中?

The question Loading a PowerShell hashtable from a file? documents how to load a file that contains a hashtable in PSON format into a variable, but how does one save a hashtable to a file in PSON format?

哈希表:

@{            
 "name" = "report 0"            
 "parameters" = @(
    @{"name" = "parameter 0"; "default" = 1; "values"=1,2,3,4},
    @{"name" = "parameter 1"; "default" = 'A'; "values" = 'A','B','C'}
    )            
}

推荐答案

尝试 *-CliXml cmdlet.保存对象:

Try the *-CliXml cmdlets. To save the object:

@{            
 "name" = "report 0"            
 "parameters" = @(
    @{"name" = "parameter 0"; "default" = 1; "values"=1,2,3,4},
    @{"name" = "parameter 1"; "default" = 'A'; "values" = 'A','B','C'}
    )            
} | Export-Clixml -Path c:hash.xml

要回读:

Import-Clixml c:hash.xml

这篇关于以 PowerShell 对象表示法 (PSON) 保存哈希表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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