The only way to calculate the size of the home drive would be to add up the size of all the files in the home drive. You’d use Get-ChildItem (dir) to produce a list of files, and probably have it -recurse through subfolders, and then probably pipe that to Measure-Object, using the -sum option to generate the total size. It’s going to be fairly time-consuming, and if this is on a file server could generate a certain amount of load. And you’re not going to be able to do this in a straightforward one-liner. It’ll be something like…
Get-ADUser -filter * -properties department, whencreated, homedrive, homedirectory |
$size = Dir $_.homedirectory -recurse | measure -sum
$_ | Add-Member -MemberType NoteProperty -Name Size -Value $size.sum
} | Ft Name, department, whencreated, homedrive, home directory, size
That’s probably not 100% going to work, but it’s the basic gist. I’m adding a Size property to the user object, so that you can display that in your table.
Unless your “Get-Size” function is a real thing that’s already doing this.