Using New-PSDrive -Persist, i.e. creating a persistent drive mapping at the OS level, is only supported on Windows.
While trying to use it on Unix-like platforms does report an error, the error message is confusing (see below).
Steps to reproduce
New-PSDrive -root '\\foo\bar\' -name N -PSProvider filesystem -Persist
Expected behavior
The error message should indicate that the host platform is not supported, along the lines of System.PlatformNotSupportedException
Actual behavior
The following error is reported:
New-PSDrive : When you use the Persist parameter,
the root must be a file system location on a remote computer.
The reason is that the code currently blindly follows a Windows code path until it eventually hits the PathIsNetworkPath() method in FileSystemProvider.cs, which categorically returns false on Unix.
Environment data
PowerShell Core 6.2.0-preview.1 on macOS 10.14
PowerShell Core 6.2.0-preview.1 on Ubuntu 16.04.5 LTS
Using
New-PSDrive -Persist, i.e. creating a persistent drive mapping at the OS level, is only supported on Windows.While trying to use it on Unix-like platforms does report an error, the error message is confusing (see below).
Steps to reproduce
Expected behavior
The error message should indicate that the host platform is not supported, along the lines of
System.PlatformNotSupportedExceptionActual behavior
The following error is reported:
The reason is that the code currently blindly follows a Windows code path until it eventually hits the
PathIsNetworkPath()method inFileSystemProvider.cs, which categorically returnsfalseon Unix.Environment data