【发布时间】:2017-09-24 09:28:51
【问题描述】:
我有一个 PowerShell 脚本,其中包含 $arrayip 和 $hash。我想将 $arrayip 中的每个 IP 地址添加为我的 $hash 哈希表中的名称或键。
我的语法错误:
$arrayip = @("192.168.1.1", "192.168.1.2", "192.168.1.3")
$hash = @{
name = "Name"
$arrayip = "Is a server IP"
}
对我来说结果不好:
PS C:\> $哈希 名称 值 ---- ----- 姓名 姓名 {192.168.1.1, 192.168.1.2, ... 是服务器IP【问题讨论】:
-
你想要的结果是什么?您希望地址成为哈希表中的键还是值?这是一个根本的区别。保存地址后,您想对哈希做什么?
-
是的,先生,我想将每个 ip 添加为键,并且值相同
标签: windows powershell hashtable