Powershell ‘Documents’ or ‘My Documents’


Can anyone explain why using something like:


When looking at the output it is actually returning:


The “My Music” and “My Pictures” are not under that location, but “Documents” or “My Documents” seems to report all of these folders.

However, if I use ‘dir’ it ONLY returns the files that are physically under ‘My Documents’. Also if I gci ‘My Pictures’ it ONLY returns the contents of ‘My Pictures’ I know the various profile folders are special folders but is there a way to JUST return the contents of ‘My Documents’.

My script is basically parsing the user profiles and returning the size of all machines in preparation for redirected profiles.

So the output is always something like:

So in the example the ‘Total’ is actually just reporting the 500 MB of pictures, one in ‘My Pictures’ and once in ‘My Documents’


This is not powershell specific, this is because Windows 7 has Junctions in any profile under the Documents folder for My Music, My Pictures, and My Videos. This can be seen by pulling up a command prompt, navigating to your Documents folder, and doing a DIR /AD which will show you those junctions.

To avoid this problem within PowerShell do not use the -Force option, and it should not include junctions.

This behavior can be seen by doing the same within PowerShell as well if you would prefer, by performing GCI $env:UserProfile\Documents and noting there is no listing for the three junctioned folders, and then doing the same but appending -Force to it and noting that those three now appear.

As pointed out by Rob Prouse, this only works if the user’s Documents folder is located in the default location. If it has been redirected somewhere else then it will not get you that redirected location. It works for the OP’s original issue, since they were obviously looking at the default location, but for other users you will want to get the path using [environment]::GetFolderPath('MyDocuments')


Powershell ‘Documents’ or ‘My Documents’ by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply