在PowerShell中,如何确定当前驱动器是否为联网驱动器?

JJa*_*ava 7 c# powershell networking mapped-drive

我需要知道,在Powershell中,当前驱动器是否是映射驱动器.

不幸的是,Get-PSDrive没有像预期的那样工作:

PS:24 H:\temp
>get-psdrive  h

Name       Provider      Root      CurrentLocation
----       --------      ----      ---------------
H          FileSystem    H:\          temp
Run Code Online (Sandbox Code Playgroud)

但在MS-Dos中,"net use"表明H:实际上是一个映射的网络驱动器:

New connections will be remembered.

Status       Local     Remote                    Network
-------------------------------------------------------------------------------
OK           H:        \\spma1fp1\JARAVJ$        Microsoft Windows Network

The command completed successfully.
Run Code Online (Sandbox Code Playgroud)

我想要做的是获取驱动器的根目录并在提示符中显示它(请参阅:自定义PowerShell提示符 - 相当于CMD的$ M $ P $ _ $ + $ G?)

Jef*_*ong 10

使用.NET框架:

PS H:\> $x = new-object system.io.driveinfo("h:\")
PS H:\> $x.drivetype
Network
Run Code Online (Sandbox Code Playgroud)