powershell - Powershell哈希表

标签 powershell hashtable

我正在尝试使用以下代码创建自定义哈希表,但未获得任何输出

foreach ($user in $users){
$files = Get-ChildItem -Recurse "\\192.168.1.2\c$\user\$user"
$totalsize = ($files | Measure-Object -Sum Length).sum / 1mb
$totalsize = [decimal]::round($totalsize) 

$output=@{"User"="$user" ; "Size" = "$totalsize"}

最佳答案

这样效果更好吗?

$Output = 
 foreach ($user in $users){
  $files = Get-ChildItem -Recurse "\\192.168.1.2\c$\user\$user"
  $totalsize = ($files | Measure-Object -Sum Length).sum / 1mb
  $totalsize = [decimal]::round($totalsize)
  @{"User"="$user" ; "Size" = "$totalsize"}
  }

$output

关于powershell - Powershell哈希表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20204199/

相关文章:

Python 日期哈希表

c - 具有特定要求的纯C通用双向哈希表

java - Eclipse 调试器中显示的哈希表值

java - java中为什么HashTable存储表中key的hash值

hashtable - Freemarker Hashtable<Integer, String>,按键迭代

powershell - 复制文件夹结构和特定文件夹的内容

windows - Powershell - 具有多个函数和 ArgumentList 的调用命令

powershell - 读取所有文件,更改内容,再次保存

windows - 安装/卸载 Windows 服务

powershell - 如何在尝试保存文件名之前去除非法字符?