Problem with snapin and client registery keys
- FOG Version: 1.4.4
- OS: CentOS 7
- Service Version: 0.11.12
- OS: Windows 10
I have a problem with a Powershell script.
I want to add some register keys to all clients. Everything in this Powershell script is working just fine only for the register keys. Snapin task give no errors.
I have read a article on the internet that the service on the client is running as SYSTEM user.
How can i do this within a Powershell script?
Here is some of my register keys within the powershell script.
New-Item -Path HKCU:\Software\Test -Force New-ItemProperty -Path "HKCU:\SOFTWARE\Test" -Name "Machinenummer" -Value $env:computername -PropertyType String -Force | Out-Null
I have tried many ways and it seems that powershell can’t do this or i missed something.
What i have tried now is to make a snapin pack with psexec.exe and a batch file.
Also in this batch i can’t write to HKCU.
I used now the following code to store the key and this works for now. It’s not a nice solutions but it works.
If anyone can give me the trick to do this in powershell, let me know.
PsExec.exe -i -s -u %COMPUTERNAME%\%username% -p -nobanner -accepteula -i REG ADD "HKLM\SOFTWARE\Test" /v "Machinenummer" /t REG_SZ /d %COMPUTERNAME% /f
HKCUaka HKEY_CURRENT_USER is different depending on the user being logged on to the computer. So trying to set keys or values within a script that is run by the fog-client (as system service) won’t give you the expected outcome I reckon.
Read this: https://stackoverflow.com/questions/2365367/how-to-access-hkcu-registry-of-currently-logged-on-users-from-a-service as well as https://social.msdn.microsoft.com/Forums/vstudio/en-US/cef6584d-d05e-4510-a7c2-7ab529c303f9/setting-user-registry-keys-hkcu-from-a-local-system-account-service?forum=vcgeneral - there you find some interesting suggestions on how to find logged on users, get their SID or impersonate this users…
Maybe you could go a different way as well. Snapin places the powershell script into the user’s autorun folder which is executed on logon…