0

I have two drives on the computer I am currently working: c: and d:. When I switch between these cd c:, cd d:, PowerShell remembers the location of the last path I was in the respective drive. I believe this path should be accessible by the value of currentLocation of the object returned by get-psDrive. However, it turns out, currentLocation is empty for the d: drive (although the path is remembered) when I cd into d: again:

PS C:\> cd C:\Users\Rene\
PS C:\Users\Rene> d:
PS D:\> cd .\bla\
PS D:\bla> get-psDrive -psProvider fileSystem  | select-object name, currentLocation

Name CurrentLocation
---- ---------------
C    Users\Rene
D

I assume that this discrepancy is because the d: drive is an external USB drive. If this is the case, I'd like to know if this is by design and how I can get the current path for the d: drive.

René Nyffenegger
  • 2,249
  • 7
  • 33
  • 46
  • Which Windows version are you on? I cannot duplicate your problem. The `CurrentLocation` property is only blank when the location is the root. – harrymc Oct 03 '19 at 08:40
  • `[environment]::osVersion.VersionString` returns `Microsoft Windows NT 10.0.17763.0`. – René Nyffenegger Oct 03 '19 at 08:53
  • You are on Windows 10 version 1809, so there is no reason that this wouldn't work correctly, unless system corruption. Try doing [sfc /scannow](https://www.tenforums.com/tutorials/2895-run-sfc-command-windows-10-a.html). – harrymc Oct 03 '19 at 08:56
  • `Get-Location | Select -expand Path` would be a workaround. however, I can also not duplicate your Problem with `CurrentLocation` – SimonS Oct 03 '19 at 11:44
  • I also could not replicate the behavior – Ramhound Oct 03 '19 at 12:08

0 Answers0