Run only signed PowerShell scripts (AllSigned)
Enforce the AllSigned execution policy on managed Windows devices, trust the NetLock RMM signing certificate, and sign your own scripts so the agent still runs them.
Run only signed PowerShell scripts (AllSigned)
Windows PowerShell can be told to run only scripts that carry a valid Authenticode signature (AllSigned). Organisations that enforce this through Group Policy can keep it with NetLock RMM: the scripts the agent brings along are signed, and your own scripts run when you sign them with a certificate the devices trust. There is no switch for this in the web console; the policy is yours, set and enforced by Windows.
How the agent runs PowerShell
- Built-in scripts (Windows Update, WSUS, Storage Spaces, DHCP, Terminal Server, Hyper-V and Exchange sensors) ship as fixed files under
C:\Program Files\0x101 Cyber Security\NetLock RMM\Comm Agent\Scripts, signed with the NetLock RMM code-signing certificate. The agent starts them with the execution policyRemoteSigned; a Group Policy that setsAllSignedtakes precedence and is honoured. - Your scripts (jobs, sensors, sensor actions, remote shell, App Hub script apps) are written to the protected working folder of the agent exactly as you saved them in the console. The agent does not add or change a line, so a signature block you saved with the script stays valid. The script is started through the signed wrapper
Run-Customer-Script.ps1from the folder above, with-ExecutionPolicy Bypass; under a Group PolicyAllSignedthat parameter has no effect and Windows checks the signature of your script. - Python, Bash and Zsh scripts are not affected by the PowerShell execution policy.
Before you start
-
A code-signing certificate for your own scripts: from your internal PKI (AD CS) or a public CA. A self-signed certificate works as well when you distribute it to the devices as described below.
-
The NetLock RMM code-signing certificate (public part). Export it from any signed agent file on a managed device, for example in an elevated PowerShell:
$exe = 'C:\Program Files\0x101 Cyber Security\NetLock RMM\Comm Agent\NetLock_RMM_Agent_Comm.exe' (Get-AuthenticodeSignature $exe).SignerCertificate | Export-Certificate -FilePath .\netlock-rmm-codesigning.cer
Steps
1. Trust the publishers on the devices
AllSigned runs a script only when the signing certificate chains to a trusted root and the publisher is listed under Trusted Publishers. The agent runs PowerShell non-interactively, so the "Do you want to run software from this untrusted publisher?" prompt cannot be answered; a publisher that is not trusted is simply blocked.
Deploy both certificates through Group Policy (Computer Configuration → Policies → Windows Settings → Security Settings → Public Key Policies):
Trusted Publishers: the NetLock RMM code-signing certificate and your own code-signing certificate.Trusted Root Certification Authorities: the root of your own certificate if it is not a public one (for a self-signed certificate, the certificate itself).
2. Enforce the execution policy
Computer Configuration → Policies → Administrative Templates → Windows Components → Windows PowerShell → Turn on Script Execution → Allow only signed scripts. This sets the MachinePolicy scope, which wins over every other scope and over the -ExecutionPolicy parameter.
3. Sign your scripts
Sign the script text with your certificate and save the signed text, including the signature block, in Collections → Scripts:
$cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1
Set-AuthenticodeSignature -FilePath .\Inventory.ps1 -Certificate $cert -TimestampServer http://timestamp.digicert.com
Get-Content .\Inventory.ps1 -Raw | Set-ClipboardPaste the clipboard into the script editor and save. The block at the end (# SIG # Begin signature block … # SIG # End signature block) is part of the script and must stay complete. Any later edit in the console, even a changed comment, invalidates the signature; sign the file again and paste it again.
Script variables are passed to the script through environment variables, not by editing the script text, so a signed script can use them without losing its signature. Signed scripts with variables need agent 3.3.0.11 or later.
4. Verify on a device
- Run a signed job once from the console. The job output appears as usual.
- Run an unsigned test script. The job fails with the PowerShell message that the file is not digitally signed — the expected outcome under
AllSigned. - Check a built-in: with debug logging on,
Comm Agent\Logs\PowerShell.txtshowsExecute_Builtin … script: Wua-List.ps1lines without execution-policy errors.
Notes
RemoteSignedas a Group Policy also works: built-in and local scripts run without a signature, and scripts you paste into the console are local files for Windows.- Timestamp your signatures (
-TimestampServer) so they stay valid after the certificate expires. - The PowerShell 7 installer package the agent downloads for winget and the Sysinternals tools are checked by the agent itself against Microsoft's signature before they are installed or started; they are not affected by this policy.
- With Endpoint Protection anchored devices add a second, independent check: the agent runs only definitions that were signed in the NetLock RMM app (see Appendix A.13 — Endpoint protection). The two mechanisms complement each other; neither replaces the other.