Please can anyone help with this issue.
I’m trying to calculate the size of the homedrive for each user in an AD Group and then add it to a variable to keep a running total of the homedrive sizes. I want the size of the each users homedrive and the running total size of all mailboxes to be displayed as the search progresses. I have written the following:
[int]$TotalSizeofAllHomeDrives = 0 $ADUser = (get-aduser -SearchBase "ExampleADGroup" -filter *).samaccountname Foreach ($User in $ADUser){ $SizeofUserHomeDrive = ((get-aduser -id "$User" -properties homedirectory).homedirectory | Get-ChildItem -recurse | measure-object -property length -sum).sum $SizeofUserHomeDrive += $TotalSizeofAllHomeDrives Write-Host "The size of the Home Drive for $User is $SizeofUserHomeDrive" Write-Host "Current total of all Home Drives is $TotalSizeofAllHomeDrives" }
As the search runs, the size of each users home drive is being displayed but the 'Current total of all Home Drives (the $TotalSizeofAllHomeDrives figure) always displays as 0.