使用 powershell 加载 ntuser.dat

2024-02-17

我需要检查网络中 Windows 客户端上所有用户的一些设置。所有用户都有漫游配置文件。

我编写了一个 Powershell 脚本,该脚本加载用户的 NTuser.dat 的脱机副本并读出特定的密钥。然后该文件被卸载,下一个文件被加载到注册表中。

问题是大约 10 个用户后没有加载新文件。当脚本再次启动时,用户仍然不会加载。只有在我关闭 Powershell 提示符并打开一个新提示符后,才会出现新用户。该脚本总是在大约 10 个用户后停止。

$userlist = ls "C:\Temp calls\profiles"
foreach ($user in $userlist){
$username = $user.name
#$username = "ciproda"
reg load "hklm\$username" "C:\Temp calls\profiles\$username\NTUSER.DAT" | Out-Null
...

    Here I check the keys

    ...

[gc]::collect()
start-sleep -s 3
reg unload "hklm\$username"
}

在你的部分'我在这里检查密钥',您是否使用以下内容将配置单元安装为 PS 驱动器:

new-Psdrive -name <blah> -PSProvider Registry -root <blih>
cd <blah>:
# Some Set-ItemProperty and Get-ItemProperty calls here referring to
# your PSDrive and using PowerShell variables
Remove-PSDrive <blah>

如果在调用 REG UNLOAD 之前仍有对某些 PSDrive 变量的引用,则该调用可能会失败。尝试删除仍然引用您的 PSDrive 的所有变量Remove-Variable.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 powershell 加载 ntuser.dat 的相关文章

随机推荐