Powershell: [Experimental Feature PSTempDrive ] Temp: not accessible.

Created on 13 Mar 2019  路  3Comments  路  Source: PowerShell/PowerShell

Steps to reproduce


1. Enable-ExperimentalFeature PSTempDrive
2. restart Powershell
3. Get-PSDrive, verify Temp   .... Filesystem    C:\Users\<username>\AppData\Local\Temp is listed
4. enter Temp:\ to acces PSTempDrive  



Expected behavior

changing to ~/Temp,

Actual behavior

Temp:\ : The term 'Temp:\' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Temp:\
+ ~~~~~~
+ CategoryInfo          : ObjectNotFound: (Temp:\:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Environment data

Windows 10. 0.17763 64-bit.

---- -----
PSVersion 6.2.0-rc.1
PSEdition Core
GitCommitId 6.2.0-rc.1
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Issue-Question Resolution-Answered

Most helpful comment

This has always been the case -- you can't HKLM: or whatever, and you can't C:\. The command C: is there for Command Prompt users.

BTW, C: is not Set-Location -LiteralPath C:\, it's Set-Location -LiteralPath C:, which preserves the current directory of drive C. This is a legacy of the transition from DOS to Windows.

All 3 comments

This is a bit of a fun one, actually. If I recall carrectly, C: and similar are actual defined functions that essentially call Set-Location C:\, not something PS knows how to figure out on its own.

I guess @SteveL-msft forgot to add one for Temp:

Good point, @vexx32, though note that this nod to cmd.exe is only applied to "native" filesystem drives, not to _PS_ drives such as Temp:, so I don't think anything needs to be done here.

_Update_:

  • Functions A: through Z: are _blindly_ defined on startup, whether these drives exist or not.

  • While you can also define a custom PS-only drive for an unused drive _letter_ (singular) such as P:, any PS-only drives whose name comprises _multiple_ characters, such as HKLM: - or, in this case - Temp: - is implicitly excluded.

This has always been the case -- you can't HKLM: or whatever, and you can't C:\. The command C: is there for Command Prompt users.

BTW, C: is not Set-Location -LiteralPath C:\, it's Set-Location -LiteralPath C:, which preserves the current directory of drive C. This is a legacy of the transition from DOS to Windows.

Was this page helpful?
0 / 5 - 0 ratings