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?
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.
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.
The dir cmdlet in Windows PowerShell generates a list of File and Folder objects, which PowerShell formats into a text listing after the fact.
try this:
[Environment]::GetFolderPath("MyDocuments")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With