使用 powershell 加载 ntuser.dat [英] Loading ntuser.dat with powershell

查看:79
本文介绍了使用 powershell 加载 ntuser.dat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to check some settings for all users on Windows clients in the network. All users have roaming profiles.

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

I have written a Powershell script that loads an offline copy of a users' NTuser.dat and reads out the specific keys. Then the file is unloaded and the next one is loaded into the registry.

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

The problem is that after about 10 users no new files are loaded. When the script is launched again the users still don't load. New users are only after I close the Powershell prompt and open a new one. The script always stalls after about 10 users.

$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 驱动器:

In your section 'Here I check the keys', are you mounting the hive as a PS drive using something like:

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 变量的引用,则该调用可能会失败.尝试通过 Remove-Variable 删除所有仍会引用您的 PSDrive 的变量.

If you still have references to some of your PSDrive variables before calling REG UNLOAD, that call might fail. Try to remove all variables that would still refer to your PSDrive through Remove-Variable.

这篇关于使用 powershell 加载 ntuser.dat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆