Please help me to deal with PowerShell environment variable.
I had learned that PowerShell has special syntax to access the system environment variable values. So I've tried to execute:
in the PowerShell 6.2.4 console on Windows 10. The output is strange:
It has my Windows user name shortened to the 8.3 form.
The problem is that I can't use the
cd $env:temp command, it displays the following error:
cd : An object at the specified path C:\Users\OD42B~1.BOR does not exist.
But I can do
cd %temp% in the
I've tried Windows PowerShell app (
cd $env:Temp does not works either.
I've checked environment variable configuration option (Sytem properties\Environment variables) and both
TMP variables are shown using the long form profile folder name, like
How can I make
cd $env:Temp work for a non-8.3 profile name in the PowerShell?
get-childitem env:Tempoutput is
echo %temp%output is the same
cd %temp%works in the cmd).
TEMPenvironment variable in the UI is set properly (value shown is like
TEMPvalue is shown like
%USERPROFILE%\AppData\Local\Tempwhen I try to edit
TEMPusing the UI.
get-childitem env:userprofiledisplays full name like
I've just checked PowerShell 7 rc2 but the result is the same:
cd $env:Temp does not work.
Thank you for helping me. I've found the answer provided by the @Smock comment link:
cd (gi $env:temp).fullname