Wednesday, December 13, 2006

Environment variables

To use the standard windows environment variables (temp, computername, windir, etc.) in PowerShell, you can use the following notation:

${env:temp}

Or, if the full names (not 8.3 DOS notation) are required:

[io.path]::GetFullPath($env:temp)

Note that if $env:path is needed, you have to use the first notation (which in this case returns the full path/file names).

${env:path}

[io.path]::GetFullPath($env:path) ## Won't work, as the returned value is too large.

No comments: