Skip to content

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

Closed

Description

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

Activity

  1. added
    WG-Engine-Providers
    Up-for-Grabs
    on Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-FixedUp-for-GrabsWG-Engine-Providers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions