在 PowerShell 中,如何确定驱动器的根目录(假设它是网络驱动器) [英] In PowerShell, how can I determine the root of a drive (supposing it's a networked drive)

查看:62
本文介绍了在 PowerShell 中,如何确定驱动器的根目录(假设它是网络驱动器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 PowerShell 中,即使可以知道驱动器是否是网络驱动器:请参阅 在 PowerShell 中,如何确定当前驱动器是否为网络驱动器?

In PowerShell, even if it's possible to know if a drive is a network drive: see In PowerShell, how can I determine if the current drive is a networked drive or not?

当我尝试获取驱动器的根"时,我得到驱动器号.

When I try to get the "root" of the drive, I get back the drive letter.

设置:MS-Dos "net use" 显示 H: 确实是映射的网络驱动器:

The setup: 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.

Get-PSDrive 告诉我们根是 H:

Get-PSDrive tells us that the Root is H:

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

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

并且使用 system.io.driveinfo 并没有给我们一个完整的答案:

and using system.io.driveinfo does not give us a complete answer:

PS:13 H:\
>$x = new-object system.io.driveinfo("h:\")
PS:14 H:\
>$x.DriveType
Network
PS:15 H:\
>$x.RootDirectory

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        29/09/2008     16:45            h:\

知道如何获取该信息吗?

Any idea of how to get that info?

谢谢

推荐答案

尝试 WMI:

Get-WMIObject -query "Select ProviderName From Win32_LogicalDisk Where DeviceID='H:'"

这篇关于在 PowerShell 中,如何确定驱动器的根目录(假设它是网络驱动器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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