Issue
Custom scripts referencing HKEY_Current_User (HKCU) or SYSTEM exit in a failure state.
Environment
- Datto RMM
Cause
Datto RMM jobs run as SYSTEM, which is not a current user and lacks a HKCU tree in the Windows registry. SYSTEM cannot access any key or value referenced in HKCU as a result.
Resolution
Configure your script to call on another user's registry, or change the current user in the script. Datto is unable to provide support for custom scripting or any unexpected behavior of your production environment as a result of the deployment of a custom script.
To test your script as SYSTEM, follow these steps:
1. Download PSExec.
2. Run the following command in PowerShell:
Start-Process -FilePath cmd.exe -Verb Runas -ArgumentList '/k C:\SysinternalsSuite\PsExec.exe -i -s powershell.exe'
This will open a new PowerShell instance with the user set as SYSTEM, which you can validate by running the whoami command.
3. Run your script in the same PowerShell instance. It should fail and display a similar to the following example:
Set-ItemProperty : Cannot find path
'HKCU:\Software\Microsoft\Office\Outlook\Addins\O365 Encrypt Button\' because it does not exist.
At C:\ProgramData\CentraStage\Packages\c679c3aa-078c-4bf6-b916-0b0e0808f0df#\command.ps1:1 char:1
+ Set-ItemProperty -Path "HKCU:\Software\Microsoft\Office\Outlook\Addin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKCU:\Software\...Encrypt Button\:String) [Set-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand
Head on over to our Datto Community Forum or the Datto Community Online.
For more Business Management resources, see the Datto RMM Online Help and the Autotask PSA Online Help .
Still have questions? Get live help.