15 July 2007

PowerShell: Playing with the env value

Simple question: do the same as cd %TEMP% in a cmd...

well, you have many ways in PowerShell to make the work. First, we can have a look at the TEMP variable:

PS C:\Users\gollum> get-item ENV:\TEMP

Name Value

---- -----
TEMP C:\Users\gollum\AppData\Local\Temp

After playing around a while, i found the correct way to do it:
PS C:\Users\gollum>
PS C:\Users\gollum> cd $env:TEMP
PS C:\Users\gollum\AppData\Local\Temp>

Here is an extract from what i tried without any success:
cd (get-item ENV:\TEMP select-object -property value)
cd < get-item ENV:\TEMP select-object -property value

No comments: