Get Home Directory Size for User

I’m very new to powershell and wondered if somebody might be able to help with an issue please.

I’m trying to return the size of a home drive for a specific user. The code I have come up with is:

get-aduser -identity 'userADname' -properties homedirectory | get-childitem homedirectory -recurse | measure-object -property length -sum

I’m obviously replacing ‘userADname’ with a relevant AD username.

The error I’m getting is:

get-childitem : The input object cannot be bound to any parameters for the command either because the
command does not take pipeline input or the input and its properties do not match any of the parameters that
take pipeline input.

Thank you for any help.

Looking at the documentation for Get-ChildItem (Get-Help Get-ChildItem), there are 2 parameters that can take arguments over the pipeline: Path and LiteralPath. Both will take arguments by PropertyName and Path will also take arguments by Value. This means that:

get-aduser -identity 'userADname' -properties homedirectory

Must produce a string object to use for the Path parameter, or some other type of object that has a property named “LiteralPath” or “Path” with a string value that can be used as an argument in the Get-ChildItem command. I would recommend taking your first section of code (copied above) and pipe it to Get-Member. This will tell you what type of object is being returned along with it’s properties/methods. This should explain why “The input object cannot be bound to any parameters for the command”

Once you have determined the object type, the next step would be to make any changes necessary to the input object so it can be used by Get-ChildItem. Recommend looking a PowerShell in a Month of Lunches chapter 9 specifically 9.5 “When things don’t line up: custom properties” for an explanation.

Thanks for your feedback Mike.

I piped to get-member and saw that there was numerous types of information being returned, so I’m thinking that I need to tell it to specifically look at the HomeDirectory info?

I’ve tried the following:

get-aduser -identity 'userADname' -properties homedirectory | select-object -property homedirectory | get-childitem -recurse | measure-object -property length -sum

This is throwing up a new error about not being able to find the path. I might be completely on the wrong track as this is all still very new.

Thanks again.



Step it through 1 by 1


[pre]get-aduser testuser -properties homedirectory | select homedirectory[/pre]




This isn’t data that get-childitem can handle, get-childitem is looking for a unc path i.e \server\testuser NOT that outputted object you see above. You can get what you need two different ways

[pre]get-aduser testuser -properties homedirectory | select -expandproperty homedirectory [/pre]

[pre](get-aduser testuser -Properties homedirectory).homedirectory[/pre]

Which both output as:


Which you can successfully pipe to get-childitem


Thanks Jon, that’s great. Looking at the outputs after removing the pipes and adding them 1 by 1 helped to make sense of it and it’s working now.

Is there an easy way of getting it to show the size in GB rather than bytes or is that adding a lot more complexity?

Thanks Jon, that’s really helpful.