I need to check some settings for all users on Windows clients in the network. All users have roaming profiles.
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.
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"
}