有关powershell嵌套哈希表的例子,嵌套哈希表对于多维数组是一个更好选择,这种存储方式将更易于管理。
例子:
复制代码 代码示例:
$person = @{}
$person.Name = 'Weltner'
$person.Id = 12
$person.Address = @{}
$person.Address.Street = 'Canyon Rim'
$person.Address.City = 'Folsom'
$person.Address.Details = @{}
$person.Address.Details.Story = 4
$person.Address.Details.ScenicView = $false
更好的写法:
复制代码 代码示例:
$person = @{
Name='Weltner';
ID=12;
Address=@{
Street='天上人间';
City='北京';
Details = @{
Story='牛鬼蛇神他的妃子们';
ScenicView=$false
}
}
}
此脚本定义了一个用户,可以查看这个用户的全部信息:

将更容易获取其中的单个信息:
