在PowerShell中,我怎么能确定当前的驱动器是一个网络驱动器或不? [英] In PowerShell, how can I determine if the current drive is a networked drive or not?

查看:621
本文介绍了在PowerShell中,我怎么能确定当前的驱动器是一个网络驱动器或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道,在PowerShell中,如果当前驱动器是一个映射驱动器或没有。

I need to know, from within Powershell, if the current drive is a mapped drive or not.

不幸的是,获取-PSDrive来不工作预期

Unfortunately, Get-PSDrive is not working "as expected":

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

Name       Provider      Root      CurrentLocation
----       --------      ----      ---------------
H          FileSystem    H:\          temp

但在MS-DOSNET USE显示,H:真的是一个映射网络驱动器:

but in MS-Dos "net use" shows that H: is really a mapped network drive:

New connections will be remembered.

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

The command completed successfully.



我想要做的是让驱动器的根,并在提示显示它(见: http://stackoverflow.com/questions/157923/customizing-powershell-prompt当量的其他对CMDS英里的

推荐答案

使用.NET Framework:

Use the .NET framework:

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

这篇关于在PowerShell中,我怎么能确定当前的驱动器是一个网络驱动器或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆