获取网络文件夹列表及其路径

Get a list of network folders and the path to them

帮助用 .bat 或 .PS1 编写脚本 任务如下: 您需要获取在(工作组)

的本地网络上共享的网络文件夹列表

我写了以下内容,但脚本向我显示了本地共享列表:

list.txt (echo Sh_Dir Sh_Path& echo ------------------& net share|findstr [ :\])

继续我的评论。

例如:

Listing Network Drives

有很多方法可以列出映射的网络驱动器。其中一个用途 PowerShell 的 Get-PSDrive 并检查目标根目录是否以 “\”,表示UNC网络路径:

Get-PSDrive -PSProvider FileSystem | 
Where-Object DisplayRoot -like '\*'
# Results
<#
Name           Used (GB)     Free (GB) Provider      Root                    CurrentLocation
----           ---------     --------- --------      ----                    ---------------
Z               11076,55          0,00 FileSystem    \192.168.2.107\docs  
#>

一个不错的地方是 Get-PSDrive returns 有用的附加详细信息,例如 驱动器的大小。