【问题标题】:Powershell detecting an extra mapped drivePowershell 检测到额外的映射驱动器
【发布时间】:2012-11-21 19:04:55
【问题描述】:

在 Windows PC(比如“MYPC”)上,我有多个映射驱动器;根据net use

>net use
New connections will be remembered.


Status       Local     Remote                    Network

-------------------------------------------------------------------------------
OK           X:        \\BLAHBLAH1\e$            Microsoft Windows Network
OK           Y:        \\BLAHBLAH2\e$            Microsoft Windows Network
OK           Z:        \\BLAHBLAH3\s$            Microsoft Windows Network
The command completed successfully.

但是当我在那台 PC 上运行这个 Powershell 时:

$disks = Get-WmiObject -Class Win32_MappedLogicalDisk -Filter "DeviceID='Z:'"
foreach($disk in $disks)
{
      [Console]::WriteLine("DEBUG: " + $disk.Name + " is " + $disk.ProviderName );
}

返回:

DEBUG: \\MYPC\root\cimv2:Win32_MappedLogicalDisk.DeviceID="Z:",SessionID="4491554321" is \\OTHERPC\c$\
DEBUG: \\MYPC\root\cimv2:Win32_MappedLogicalDisk.DeviceID="Z:",SessionID="3129225404" is \\BLAHBLAH3\s$
DEBUG: \\MYPC\root\cimv2:Win32_MappedLogicalDisk.DeviceID="Z:",SessionID="5884378361" is \\BLAHBLAH3\s$

这些其他 Z 映射驱动器是从哪里来的?它们如何占用相同的驱动器号?我可以判断它们是否可以安全移除,如果可以,如何移除?

MYPC 实际上是一个服务器,所以我不能只清除所有映射的驱动器(我通常会这样做)。

如果这是由于其他用户显示了映射驱动器,我如何更改 Powershell 以缩小到仅登录用户(net use 的具体操作方式)?

【问题讨论】:

    标签: networking powershell windows-xp


    【解决方案1】:

    您是否尝试测试设备的可用性或状态属性? 这可能会导致本地登录用户使用网络驱动器,请参阅底部的备注
    http://msdn.microsoft.com/en-us/library/windows/desktop/aa394194(v=vs.85).aspx
    也许您正在运行终端服务器,因此请检查 Win32_LogonSession 类以获取有关 providerName 中看到的会话 ID 的更多信息

    【讨论】:

    • 是的,这似乎是在正确的道路上......我必须过滤掉任何不是来自我登录用户的映射驱动器。
    猜你喜欢
    • 1970-01-01
    • 2021-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 2018-07-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多