powershell - 如何在Powershell中输出多个哈希表

标签 powershell

我有一个由键/值对的哈希表组成的哈希表(来自 .ini 文件)。它看起来像这样:

Name                           Value                                                                   
----                           -----                                                                   
global                         {}                                                                      
Variables                      {event_log, software_repo}                                               
Copy Files                     {files.mssql.source, files.utils.source, files.utils.destination, fil...

如何在一个哈希表中输出所有键/值对,而不是这样做?

$ini.global; $ini.variables; $ini."Copy Files"

最佳答案

鉴于 $hh 是哈希表的哈希表,您可以使用循环:

foreach ($key in $hh.keys)
{
  Write-Host $hh[$key]
}

关于powershell - 如何在Powershell中输出多个哈希表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10935836/

相关文章:

powershell - azure VM中未加载指定的模块 'SQLPS'

string - 使用PowerShell查找字符串中的差异

powershell - 调用powershell.exe给出参数设置错误

用于获取所提供用户名的订阅列表的 Powershell 脚本

arrays - 如何从PowerShell中的数组中删除项目?

powershell - 如何更改我键入的字符串值的颜色?

powershell - Powershell 中的显式返回

powershell - 在 Invoke-WebRequest 调用中信任自签名证书

sharepoint - 无法使用Sharepoint PowerShell更新列表字段属性

powershell - 如何解决测试连接错误 : "A parameter cannot be found that matches parameter" name 'TargetName' . "