A while ago I had pointed to a blog post I found wherein the author wrote a script to push registry keys to the NTUSER.DAT profile file of a large number of users. I wanted to try something similar in my own environment and while I didn’t go with the script I found I made up something quick and dirty of my own. I know it isn’t as thorough as the one from that blog post (so I’ll link to it again) but it serves my need. :)
So here’s the deal. I have a bunch of profiles located at “\\path\to\profiles\ctxprofiles$
“. It has both v4 and v6 profiles. I’d only like to target the v4 profiles, and that too a specific user for testing. This user’s name contains the word “CtxTest” so I match against it. (Post testing I can remove the pipeline and target everyone).
1 2 3 4 5 6 7 8 9 10 11 12 |
Get-ChildItem \\path\to\profiles\ctxprofiles$\*.v4 | ?{ $_.Name -match "CtxTest" } | %{ $DatFile = "$($_.FullName)\UPM_Profile\NTUSER.DAT"; Write-Host -ForegroundColor Green "Filename $DatFile" Write-Host "Loading: " -NoNewline REG LOAD HKU\DefaultUser $DatFile; Write-Host "Importing: " -NoNewline REG IMPORT '\\path\to\a reg file.reg' Write-Host "Unloading: " -NoNewline REG UNLOAD HKU\DefaultUser } |
All I do is get the list of folders, and for each of them load the NTUSER.DAT
file from the correct location (it’s under a folder called UPM_Profile
as I am using Citrix UPM). I just use the REG
commands to load the registry hive, import a registry file, and unload the hive. Easy peasy. No error checking etc. so like I said it’s not as great a script as it can be.