Call Set-Location or cd
PS C:\Users\gakama\Desktop> set-location D:\
PS D:\> cd
PS C:\Users\gakama> set-location D:\
PS D:\> Set-Location
PS C:\Users\gakama>
Without any parameters, it shouldn't change the current location.
Here's the output from Powershell 5.1
PS C:\Users\gakama\Desktop> Set-Location d:
PS D:\> cd
PS D:\>
The location changes to "%USERPROFILE%" (C:\Users\<username>)
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.2
PSEdition Core
GitCommitId v6.1.0-preview.2
OS Microsoft Windows 10.0.16299
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This was an explicit design decision (and yes, a breaking change from Windows PowerShell) mimicking Bash
Coming from Windows it caught me by surprise.
Is this change documented?
@iSazonov created https://github.com/PowerShell/PowerShell-Docs/pull/2480
@SteveL-MSFT It's really amazing behavior on Windows because Windows users expect in contrast to Unix that default working directory is Documents not profile root folder.
/cc @mklement0 What do you think?
@iSazonov:
The behavior is consistent: the equivalent locations - $HOME - are targeted on all platforms.
It is a fact of Windows life that creating files and folders _directly_ in $HOME is _ill-advised_ - albeit _possible_. Yes, using Documents for user-created content is the right choice, but it is only a _convention_.
This asymmetry in how the $HOME folder is used between Unix-like platforms and Windows is unfortunate, but in this case I think it's more important to be consistent and stick with the well-defined, directly equivalent $HOME on all platforms.
That said, it would generally be handy for Set-Location to support the special / well-known folders supported by [Environment]:: via the [Environment+SpecialFolder] enumeration, so that you could do something like:
Set-Location -SpecialFolder MyDocuments
See #6966
Most helpful comment
@iSazonov created https://github.com/PowerShell/PowerShell-Docs/pull/2480