Find a command
Choose a platform, search by task or command, and review the safety label. Placeholders such as <container> and <PID> must be replaced before use.
PowerShell: run and digitally sign .ps1 scripts
Open Windows Terminal and choose PowerShell. Replace example paths and thumbprints with your own.
1. Run a script
Set-Location "C:\Scripts"
pwsh -NoProfile -File ".\audit.ps1"Use powershell.exe for Windows PowerShell 5.1. From an existing PowerShell prompt, & ".\audit.ps1" also works.
2. Find a signing certificate
Get-ChildItem Cert:\CurrentUser\My -CodeSigningCertTo distribute signed scripts, use a suitable code-signing certificate with its private key. A self-signed test certificate is not automatically trusted elsewhere.
3. Sign your .ps1 file
$cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert |
Where-Object Thumbprint -eq "<THUMBPRINT>"
Set-AuthenticodeSignature -FilePath ".\audit.ps1" -Certificate $certFor timestamping, use the timestamp service specified by your certificate provider.
4. Verify the signature
Get-AuthenticodeSignature ".\audit.ps1" |
Select-Object Status,StatusMessage,SignerCertificateCheck for a Valid status on the target machine. A signature confirms integrity and signer identity under the trust policy, not code safety.
Execution policy: Start with Get-ExecutionPolicy -List. If appropriate for a trusted script, Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned changes only the current process, unless overridden by Group Policy. Execution policy is not a security boundary.