MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
November
Sun Mon Tue Wed Thu Fri Sat
           
24 28 29
30            
2025
Months
NovDec


Mon, Nov 24, 2025 7:46 pm

Determining the location of a user's "My Documents" folder with PowerShell

I needed to move some files from one Windows 11 system that is no longer being used, as the user is no longer working for the company, to another Windows 11 system where the user of that system, Pam, is now handling a task formerly handled by the prior employee, but while logged onto the account for the user now handling the task on her system, I noticed that her Documents folder was empty. The Windows domain name changed at that business a few years ago, so I thought that perhaps she might be using a Documents directory associated with her account under the prior domain name rather than the new one created for her new domain login. You can determine the location of a user's "My Documents" directory, which can be redirected to another location, including a network share or another drive, by issuing the PowerShell command [Environment]::GetFolderPath("MyDocuments"). E.g.:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\Pam> [Environment]::GetFolderPath("MyDocuments")
C:\Users\Pam\Documents
PS C:\Users\Pam>

The command utilizes the GetFolderPath method from the System.Environment class to retrieve the path of special folders, including "MyDocuments," for the user under whose context the script or command is executed. This method correctly identifies the mapped location even if the Documents folder has been redirected or moved from the default location.

In this case, I found that her "My Documents" directory was pointing to the directory associated with the old domain name. Her "home" folder was also pointing to the home folder that was in use for her account in the old domain. You can type $home in a PowerShell window to see that value. Or you can use $env:USERPROFILE to see the same information.

PS C:\Users\Pam> $Home
C:\Users\Pam
PS C:\Users\Pam >$env:userprofile
C:\Users\Pam
PS C:\Users\Pam>

[/os/windows/PowerShell] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo