【问题标题】:Get a list of network folders and the path to them [closed]获取网络文件夹列表及其路径[关闭]
【发布时间】:2021-10-16 04:25:45
【问题描述】:

帮助在 .bat 或 .PS1 中编写脚本 任务如下: 您需要获取(工作组)中本地网络上共享的网络文件夹列表

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

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

【问题讨论】:

  • 快速搜索会发现网络上和 Youtube 上都有很多此类用例的示例。

标签: powershell batch-file command


【解决方案1】:

继续我的评论。

例如:

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 返回有用的附加详细信息,例如 驱动器的大小。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-15
    • 2017-06-03
    • 2019-12-17
    • 1970-01-01
    • 2014-11-05
    • 2012-08-10
    • 1970-01-01
    相关资源
    最近更新 更多