Skip to content

New-PSDrive -Persist should report a platform-not-supported error (System.PlatformNotSupportedException) on Unix-like platforms #8250

@mklement0

Description

@mklement0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions