Getting the user's Documents folder in Powershell

Zulgrib picture Zulgrib · Jul 16, 2014 · Viewed 21.4k times · Source

I want to use a PowerShell script to automate tasks related to the user when the user logs in.

Sometimes a user will have moved his Documents folder from the default location. How can I determine the location of the user's Documents folder in PowerShell?

Answer

CB. picture CB. · Jul 16, 2014

try this:

[Environment]::GetFolderPath("MyDocuments")