【发布时间】:2015-08-03 09:42:16
【问题描述】:
我需要在远程会话中获取真实映射的驱动器,我读取了路径和名称的远程注册表,但 \Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2 中缺少标签(驱动器号)
如果我阅读 HKCU\Network,我只有永久驱动器(状态为 Replace 的 GPP 驱动器丢失)。
如何找到路径、名称和标签?
function get-Drives {
param ( [ValidateNotNullOrEmpty()] $Computername, [ValidateNotNullOrEmpty()] $SID )
try {
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('USERS', $computerName)
$RegKey = $Reg.OpenSubKey("$SID\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MountPoints2")
$lecteurs = $RegKey.GetSubKeyNames()
$lecteurs | ?{$_ -notlike '{*}'} | %{
$RegKey = $Reg.OpenSubKey("$SID\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MountPoints2\\$_")
$_LabelFromReg = $regKey.GetValue('_LabelFromReg')
if ($_LabelFromReg) {
[pscustomobject]@{
Name = $_LabelFromReg
Label = ''
Path = $_ -replace('#','\')
}
}
}
} catch {
}
}
【问题讨论】:
-
你还没有说为什么你需要为用户的远程会话获取真正的映射驱动器。
-
我为帮助台创建了一个工具软件(4000 RDC Sessions)
-
这不能回答问题。映射驱动器通常是每个用户的设置或在 GPO 中定义。为帮助台创建工具软件与为远程用户会话获取映射驱动器有什么关系?
-
GPP挂载的用户驱动器,用户只知道每个驱动器的标签或名称,但技术人员需要真正的路径来了解用户,这个工具是用户和技术人员之间的链接。因为 gpedit.msc 很难快速阅读
-
让用户启动
cmd.exe并运行命令net use。此输出告诉您映射的驱动器。尝试远程确定容易出错。
标签: windows powershell registry remote-access