Getting% AppData% path in PowerShell

How can I get the path to the application data directory (e.g. C:\Users\User\AppData\Roaming ) in PowerShell?

+43
scripting powershell
Apr 12 2018-12-12T00:
source share
3 answers

This is the shortest way:

 $env:APPDATA 

or for local application data:

 $env:LOCALAPPDATA 
+69
Apr 12 2018-12-12T00:
source share

To get the AppData directory, use the GetFolderPath method:

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

Or, as Andy mentions in his comment, simply:

 [Environment]::GetFolderPath('ApplicationData') 
+5
Apr 12 2018-12-12T00:
source share
 $TempInstallerPath="$Env:USERPROFILE\AppData\Local\Downloaded Installations" if(Test-Path $TempInstallerPath) { Remove-Item "$TempInstallerPath\*" -Recurse -Force -ErrorAction 0 } 
+4
Aug 21 '13 at 16:53 on
source share



All Articles