gpt4 book ai didi

shell - 如何在 Powershell 中获取断开连接的网络驱动器?

转载 作者:行者123 更新时间:2023-12-01 11:15:13 29 4
gpt4 key购买 nike

我需要获取所有映射的网络驱动器,甚至是当前断开连接的网络驱动器。我用 Get-PSDrive 试过了,但它只显示了当前连接的那些。可以使用 net use 获取所有映射的网络驱动器,但我不能重复使用输出(我需要保存字母和路径)。

最佳答案

虽然 James C. 发布的 HKCU 路径解决方案可能是更好的解决方案,但您可以将 net use 的输出获取到对象中。看...

net use |
Select-Object -SkipLast 2 |
Select-Object -Skip 6 |
ForEach-Object {$_ -replace '\s{2,}', ', '} |
ConvertFrom-Csv -Header Status, DriveLetter, UNC_Path, Network |
Select-Object -Property DriveLetter, UNC_Path

希望对你有帮助,

关于shell - 如何在 Powershell 中获取断开连接的网络驱动器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52758294/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com