Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the user's Documents folder in Powershell

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?

like image 388
Zulgrib Avatar asked Jul 16 '14 02:07

Zulgrib


People also ask

How do I get a list of folders in PowerShell?

On a Windows computer from PowerShell or cmd.exe, you can display a graphical view of a directory structure with the tree.com command. To get a list of directories, use the Directory parameter or the Attributes parameter with the Directory property. You can use the Recurse parameter with Directory.

How do I get a list of files in PowerShell?

To display the directory content, Get-ChildItem cmdlet is used. You need to provide the path of the directory or if you are in the same directory, you need to use only Get-ChildItem directly.

What is the DIR command in PowerShell?

The dir cmdlet in Windows PowerShell generates a list of File and Folder objects, which PowerShell formats into a text listing after the fact.


1 Answers

try this:

[Environment]::GetFolderPath("MyDocuments") 
like image 125
CB. Avatar answered Sep 19 '22 13:09

CB.