从用户配置文件位置 NTUSER.DAT 读取映射的驱动器
Read mapped drives from user profile location NTUSER.DAT flie
我想从用户配置文件服务器 NTUSER.DAT 文件中获取映射的网络驱动器信息。你能告诉我从哪里开始吗?我确实在网上找到了一些脚本,但它们没有用。我需要搜索每个配置文件(注册加载)并获取网络驱动器信息,然后卸载。
如有任何帮助,我们将不胜感激。
$user = "admin"
$profiles = get-aduser -filter {SamAccountName -eq $user} -properties *
$sid= $profiles.sid
$profile = " \serverprofile\drive$\ $user\NTUSER.DAT"
Reg load "HKU$sid" $profile
Reg export "HKU$sid\network" "C:\temp$user\network.reg"
[gc]::collect()
Reg unload "HKU$sid"
谢谢
我不在域中进行测试,但假设您启用了远程处理,则可以通过以下工作从 LAN 上的计算机加载配置单元:
$UserName = "USERNAME"
$Domain = "COMPUTERNAME"
$Cred = Get-Credential -Message "Credentials are required to access $Domain"
$CimServer = New-CimSession -ComputerName $Domain -Credential $Cred
$User = Get-CimInstance -ClassName Win32_UserAccount -CimSession $CimServer | Where-Object {
$_.Name -eq $UserName
} | Select-Object -Property Name, SID
$UserProfile = Get-CimInstance -ClassName Win32_UserProfile -CimSession $CimServer | Where-Object {
$_.SID -eq $User.SID
} | Select-Object -ExpandProperty LocalPath
$UserProfile = Split-Path -Path $UserProfile -NoQualifier
New-PSDrive -Name Remote -PSProvider FileSystem -Credential $Cred -Root \$Domain\C$ | Out-Null
$RegKey = "HKU\Remote-$($User.SID)"
$OldLocation = Get-Location
Set-Location Remote:$UserProfile
reg load $RegKey NTUSER.dat
[gc]::collect()
reg unload $RegKey
Set-Location $OldLocation
Remove-PSDrive -Name Remote
我想从用户配置文件服务器 NTUSER.DAT 文件中获取映射的网络驱动器信息。你能告诉我从哪里开始吗?我确实在网上找到了一些脚本,但它们没有用。我需要搜索每个配置文件(注册加载)并获取网络驱动器信息,然后卸载。
如有任何帮助,我们将不胜感激。
$user = "admin"
$profiles = get-aduser -filter {SamAccountName -eq $user} -properties *
$sid= $profiles.sid
$profile = " \serverprofile\drive$\ $user\NTUSER.DAT"
Reg load "HKU$sid" $profile
Reg export "HKU$sid\network" "C:\temp$user\network.reg"
[gc]::collect()
Reg unload "HKU$sid"
谢谢
我不在域中进行测试,但假设您启用了远程处理,则可以通过以下工作从 LAN 上的计算机加载配置单元:
$UserName = "USERNAME"
$Domain = "COMPUTERNAME"
$Cred = Get-Credential -Message "Credentials are required to access $Domain"
$CimServer = New-CimSession -ComputerName $Domain -Credential $Cred
$User = Get-CimInstance -ClassName Win32_UserAccount -CimSession $CimServer | Where-Object {
$_.Name -eq $UserName
} | Select-Object -Property Name, SID
$UserProfile = Get-CimInstance -ClassName Win32_UserProfile -CimSession $CimServer | Where-Object {
$_.SID -eq $User.SID
} | Select-Object -ExpandProperty LocalPath
$UserProfile = Split-Path -Path $UserProfile -NoQualifier
New-PSDrive -Name Remote -PSProvider FileSystem -Credential $Cred -Root \$Domain\C$ | Out-Null
$RegKey = "HKU\Remote-$($User.SID)"
$OldLocation = Get-Location
Set-Location Remote:$UserProfile
reg load $RegKey NTUSER.dat
[gc]::collect()
reg unload $RegKey
Set-Location $OldLocation
Remove-PSDrive -Name Remote