首页 > 解决方案 > 获取 NAS 驱动器信息

问题描述

我想使用以下命令获取 NAS 驱动器的详细信息,例如所有者、访问权限、路径等,但是,它并没有给出我期望得到的内容:

Get-PSDrive -PSProvider FileSystem | %{$_.Root }
A:\
C:\
D:\
Y:\
Z:\

When I run only first part of the command like below..
Get-PSDrive -PSProvider FileSystem

Name           Used (GB)     Free (GB) Provider      Root                                               CurrentLocation
----           ---------     --------- --------      ----                                               ---------------
A                                      FileSystem    A:\
C                  26.82         23.18 FileSystem    C:\                                     Users\sa-its-sd-na-vco2d-d
D                    .03          9.96 FileSystem    D:\
Y                 112.84        137.16 FileSystem    \\exmaple.hac.com\opp$
Z                                      FileSystem    Z:\

我的意图是得到\\exmaple.hac.com\opp$但没有得到。知道如何获取它吗?

标签: powershell

解决方案


问题是,你正在使用Root但你想要DisplayRoot.

我认为您也可以使用select

Get-PSDrive -PSProvider FileSystem | Select DisplayRoot

将输出如下内容:

A:\
C:\                   
D:\
\\exmaple.hac.com\opp$
Z:\

这将只选择 Root 列。如果您想要更多,例如 Name 和 DisplayRoot:

Get-PSDrive -PSProvider FileSystem | Select Name,Root

推荐阅读