Question

Is there a way to use either KNOWNFOLDERID or CSIDL in PowerShell?

I need to be able to access some "known folders" via PowerShell script on a variety of systems. The problem is that those folders' names tend to differ between languages and Environmental Variables list (e.g. $env:something) does not contain folders I am interested accessing in (e.g. C:\Users).

Was it helpful?

Solution

Use the .NET method System.Environment.GetFolderPath like so:

[Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData)

The MSDN topic on the Environment.SpecialFolder enum shows all the possible special folders you can ask for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top