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
On _Windows_:
New-PSDrive -root '\\foo\bar\' -name N -PSProvider filesystem -Persist
Drive creation should succeed.
The following error occurs:
New-PSDrive : The network resource type is not correct
Simply removing the trailing \ makes the problem go away.
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)
@mklement0
Interesting!! I got a different error in all of my systems: Linux and Windows, In either PowerShell Core GA 6.1.0 and Preview 6.2.0-Preview.1.
... To use the Persist switch parameter, the drive name must be supported by the operating system (for example, drive letters A-Z).
At line:1 char:1
+ new-psdrive -root "\\xxxxx\xxxx" -name Shared1 -PSProvide ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Shared1:PSDriveInfo) [New-PSDrive], InvalidOperationException
+ FullyQualifiedErrorId : DriveNameNotSupportedForPersistence,Microsoft.PowerShell.Commands.NewPSDriveCommand




Definitely! Something with the "-Persist" parameter.
:)
@MaximoTrinidad: You've hit an unrelated problem, namely that -Persist is fundamentally unsupported on Unix-like platforms, which the error message does not indicate - see #8250
I've also updated the initial post to make that clearer.
Since -Persist as it's designed today is really net use /persistent:yes so only works with UNC paths, it seems ok to just trim the trailing slash
Thanks @SteveL-MSFT and @mklement0!
:)
I found solution for me:
whats the fix for this im still getting the issue.
@alextovey I see the problem neither in v7.0 nor the current preview (3); note that only critical fixes are back-ported to _Windows PowerShell_.
Most helpful comment
Since
-Persistas it's designed today is reallynet use /persistent:yesso only works with UNC paths, it seems ok to just trim the trailing slash