-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Without the -Persist switch, you can optionally specify the root path with a trailing \ - in other words: whether or not a trailing \ is present makes no difference.
If you add the -Persist switch (Windows-only, only with single-letter drive names), a path with a trailing \ causes an obscure error:
New-PSDrive : The network resource type is not correct
Note that successful creation of the drive (without -Persist) actually retains the trailing \, as reflected in the .Root property of the drive, but it seems to have to no ill effects.
Note: A separate problem is that trying to use -Persist on Unix-like platforms, where it is fundamentally unsupported, does not indicate that fact in its error message - see #8250
Steps to reproduce
On Windows:
New-PSDrive -root '\\foo\bar\' -name N -PSProvider filesystem -PersistExpected behavior
Drive creation should succeed.
Actual behavior
The following error occurs:
New-PSDrive : The network resource type is not correct
Simply removing the trailing \ makes the problem go away.
Environment data
PowerShell Core 6.2.0-preview.1 on Microsoft Windows 10 Pro (64-bit; Version 1803, OS Build: 17134.165)
Windows PowerShell v5.1.17134.228 on Microsoft Windows 10 Pro (64-bit; Version 1803, OS Build: 17134.345)