1

I'm trying to create a custom hash table using the following code but I'm not getting any 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) 

$output=@{"User"="$user" ; "Size" = "$totalsize"}
1
  • And if you add this as the last line of your foreach statement: $output? Currently you have nothing in this statement that actually outputs anything. :-) Commented Nov 25, 2013 at 22:09

1 Answer 1

3

Does this work better?

$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
Sign up to request clarification or add additional context in comments.

1 Comment

Yup, I actually had it as a function already but didn't realize I could start the hash without anything in front of it. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.