#PSTip How to find path to your Documents folder

It’s pretty easy to find path to your Documents folder with a little help from .NET Framework’s Environment class:

PS> [Environment]::GetFolderPath('MyDocuments')
C:\Users\Administrator\Documents

You can accomplish the same using the identifier name Personal:

PS> [Environment]::GetFolderPath('Personal')
C:\Users\Administrator\Documents

How can you find all valid names? Specify a wrong name, and PowerShell will help you 🙂

PS> [environment]::GetFolderPath('wrongvalue')
Cannot convert argument "folder", with value: "wrongvalue", for "GetFolderPath" to
 type "System.Environment+SpecialFolder": "Cannot convert value "wrongvalue" to type
 "System.Environment+SpecialFolder". Error: "Unable to match the identifier name wrongvalue
 to a valid enumerator name. Specify one of the following enumerator names and try again:
 Desktop, Programs, Personal, MyDocuments, Favorites, Startup, Recent, SendTo, StartMenu,
 MyMusic, MyVideos, DesktopDirectory, MyComputer, NetworkShortcuts, Fonts, Templates,
 CommonStartMenu, CommonPrograms, CommonStartup, CommonDesktopDirectory, ApplicationData,
 PrinterShortcuts, LocalApplicationData, InternetCache, Cookies, History, CommonApplicationData,
 Windows, System, ProgramFiles, MyPictures, UserProfile, SystemX86, ProgramFilesX86, CommonProgramFiles,
 CommonProgramFilesX86, CommonTemplates, CommonDocuments, CommonAdminTools, AdminTools, CommonMusic,
 CommonPictures, CommonVideos, Resources, LocalizedResources, CommonOemLinks, CDBurning""
Share on: