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