PowerShell Code Signing: Complete Guide

PowerShell code signing uses digital signatures to associate a script with a signing identity and detect changes to its signed content. A code signing certificate and its private key are used to sign the script, while PowerShell can evaluate the signature and certificate information when determining how a script should be handled.

The important distinction is that PowerShell code signing and PowerShell execution policy are separate mechanisms. Signing provides identity and integrity information. Execution policy determines what PowerShell allows or requires under the configured policy and environment.

What is PowerShell code signing?

PowerShell code signing is the process of applying a digital signature to a PowerShell script so the script can be associated with a signing identity and its signed content can be checked for changes.

The signing process uses a private key associated with a code signing certificate. The certificate contains the corresponding public key and signer information. When the script is later inspected, PowerShell can use the signature and certificate information to determine whether the signature is valid, whether the signed content still matches the signature, and what identity is associated with the signer.

This becomes particularly important when PowerShell execution policy requires scripts to be signed. Under policies such as AllSigned, the presence and trust status of a signature can directly affect whether PowerShell permits a script to run.

Signing should not be confused with making a script safe. A valid signature can establish publisher identity and content integrity, but it doesn't prove that the script contains no vulnerable, unwanted or malicious behavior.

How PowerShell code signing fits together

A signed PowerShell script sits at the intersection of cryptographic signing, certificate trust and PowerShell's own execution-policy behavior. Each stage answers a different question.

PS1

Script

The PowerShell file being released.

HASH

Signed content

The content represented by the signature.

KEY

Private key

Creates the cryptographic signature.

CERT

Certificate

Provides signer identity and public key.

CHAIN

Trust

Connects the certificate to its issuers.

TIME

Timestamp

Adds signing-time evidence.

RUN

PowerShell

Evaluates signature and policy.

What changes when a PowerShell script is signed?

A normal PowerShell script is simply a text-based script file. Signing adds signature information that PowerShell can inspect when the file is loaded and evaluated. The important result is not that the script becomes encrypted or hidden. Its contents remain readable as PowerShell code.

Instead, the signature creates a cryptographic relationship between the script content and the signing identity. The signer certificate identifies the entity represented by the certificate and provides the public key needed to validate the signature.

The verification result can also expose certificate and timestamp information. This allows an administrator or automation system to distinguish between a script that was never signed, a script whose signed content has changed, and a script whose signature exists but cannot establish the required trust.

This is particularly useful for deployment and administration scripts because even a small change to a production script can materially change what the script does.

A signed .ps1 can expose

Identity, integrity and status

Script content: The PowerShell code being evaluated.

Signature: The cryptographic information generated during signing.

Signer certificate: The certificate associated with the signing identity.

Publisher: The identity represented by the signer certificate.

Chain and timestamp: Additional information used when evaluating trust and signing time.

Status: The resulting signature verification state.

How PowerShell code signing works

PowerShell signing is usually performed after the script has reached the version that is intended for distribution. Once the file is signed, changing the signed content can invalidate the signature, so signing should normally be one of the final release operations.

01

Create

Write and test the script.

02

Certificate

Select a suitable signing certificate.

03

Protect

Keep the private key controlled.

04

Sign

Apply the digital signature.

05

Timestamp

Add trusted signing-time evidence.

06

Verify

Check the completed signature.

07

Release

Distribute the signed script.

What is a PowerShell code signing certificate?

A PowerShell code signing certificate is a digital certificate used to establish the signing identity for a script. It contains the public key associated with the signing key and identifies the certificate subject and issuing authority.

The corresponding private key performs the actual signing operation. That distinction is critical. The certificate can be distributed as part of the signature information, while the private key should stay under the publisher's control.

Certificate selection also matters. A machine can contain multiple certificates, and not every certificate is suitable for code signing. The certificate should have the appropriate usage and an accessible private key when it is being used for signing.

The broader concepts of certificate types, validation and certificate lifecycle belong in the Code Signing Fundamentals section. This page focuses on how those certificate properties affect PowerShell.

Choose a Code Signing Certificate →
PowerShell-specific view

The certificate answers three practical questions

Who signed the script?
The certificate identifies the signer represented by the certificate subject.

Can the signature be checked?
The public key in the certificate is used as part of signature verification.

Can the signer be trusted?
The certificate and its chain are evaluated in the relevant Windows trust environment.

How Authenticode relates to PowerShell

PowerShell script signing uses the Microsoft Authenticode signing model. This means PowerShell isn't using an entirely separate certificate technology created only for PowerShell scripts.

The hierarchy is easier to understand as three connected layers: code signing is the broad practice, Authenticode is Microsoft's signing technology for supported Windows artifacts, and PowerShell applies that signing model to script files.

Code signing

The broader security practice of digitally signing software to associate it with a signer and protect the integrity of signed data.

→

Microsoft Authenticode

Microsoft's signing and verification technology for supported Windows software and signing scenarios.

→

PowerShell script signing

The PowerShell-specific use of Authenticode signatures for signed scripts and execution-policy scenarios.

What happens when PowerShell verifies a signed script?

PowerShell verification should not be reduced to "checking the certificate." The signature, signed content, signer certificate, certificate chain and local trust environment can all affect the final result.

Execution policy then adds another layer. The signature may be valid while the configured policy still imposes requirements that affect whether the script can execute. Conversely, an execution-policy problem doesn't necessarily mean the underlying cryptographic signature is broken.

01

Signature present?

Determine whether the script actually contains signing information.

02

Cryptographically valid?

Check whether the signature can be successfully verified.

03

Content unchanged?

Detect whether signed content no longer matches the signature.

04

Signer trusted?

Evaluate certificate identity, chain and applicable trust.

05

Policy satisfied?

Apply the configured PowerShell execution-policy behavior.

PowerShell execution policy and code signing

Execution policy is one of the most important reasons PowerShell signing deserves its own dedicated page. It determines how PowerShell treats scripts under a configured policy, and some policies explicitly require digital signatures for certain scripts.

The relationship is important but should not be overstated: execution policy is a PowerShell safety feature, not a complete security boundary. It should therefore be considered alongside application control, endpoint security, administrative controls and other enterprise security measures.

Restricted

Scripts are restricted

The policy places strong restrictions on script execution rather than operating as a normal "signed scripts only" mode.

AllSigned

Scripts must be signed

Scripts are required to have digital signatures, subject to the policy behavior and PowerShell environment involved.

RemoteSigned

Remote scripts require signing

Scripts obtained from remote sources generally require a trusted signature, while locally created scripts are treated differently.

Unrestricted

Fewer execution restrictions

The policy permits broader script execution while still involving PowerShell's warning and security behavior.

Bypass

Policy does not normally block

PowerShell does not apply the normal blocking behavior associated with restrictive execution policies.

Undefined

No policy at that scope

No execution policy is defined at a particular scope, so PowerShell determines the effective behavior from other applicable scopes.

Key distinction

A signature and an execution policy answer different questions

A signature asks whether the script can be associated with a signing identity and whether its signed content remains consistent with that signature. Execution policy asks how PowerShell should treat script execution under the effective policy.

A signed script can therefore still be unsafe, and an execution policy setting should not be presented as a replacement for application security controls.

What does "File is not digitally signed" mean?

This message commonly appears when PowerShell attempts to execute a script under a policy that requires a signature but the script does not meet the signing requirement.

The simplest case is an unsigned script. However, troubleshooting should not stop there. A signature can also become unusable because the script was changed after signing, the certificate is invalid or untrusted, or the verification environment cannot establish the required trust relationship.

This is why "not digitally signed" and "signed but not trusted" are different diagnostic situations. One concerns whether the required signature is available and usable; the other concerns the trust evaluation associated with an existing signature.

PowerShell error
PS C:\Scripts>
.\Deploy-App.ps1
File cannot be loaded because it is
not digitally signed.
Check execution policy and script signature.

How to sign a PowerShell script

PowerShell provides native cmdlets for working with Authenticode signatures. The normal process is to locate a suitable certificate, sign the final script, optionally add timestamp information, and then verify the completed signature.

The important operational rule is to sign the version you actually intend to release. Editing the script after signing can invalidate the signature, so signing should normally happen after development, testing and release preparation are complete.

Set-AuthenticodeSignature
  -FilePath .\Deploy-App.ps1
  -Certificate $cert
  -TimestampServer "TIMESTAMP_URL"

# Verify the resulting signature
Get-AuthenticodeSignature .\Deploy-App.ps1
Before signing

Confirm that the selected certificate is intended for code signing, that the associated private key is available to the signing process, and that the script is the final version that should be distributed. In automated environments, the private key should be protected rather than casually copied onto build machines.

How Set-AuthenticodeSignature works

Set-AuthenticodeSignature is PowerShell's native cmdlet for applying an Authenticode signature to a file. It takes the file being signed and the certificate used for the signing operation.

The certificate parameter is important because PowerShell needs access to the signing identity and corresponding private key. A certificate object without an accessible private key cannot simply be treated as a signing key.

The cmdlet can also work with a timestamp server. Timestamping provides additional signing-time information and becomes especially relevant when the certificate later reaches the end of its normal validity period.

The output should be inspected rather than ignored. A command that completes isn't a substitute for verifying the final script with Get-AuthenticodeSignature.

Set-AuthenticodeSignature
PS C:\Release>
$cert = Get-ChildItem
Cert:\CurrentUser\My
Certificate selected
Set-AuthenticodeSignature
.\Deploy-App.ps1
Signature operation completed

How to find the code signing certificate in PowerShell

Windows certificate stores provide a common place for certificates and their associated private keys. PowerShell can access certificate stores through the Cert: provider.

Two locations commonly encountered during signing workflows are Cert:\CurrentUser\My and Cert:\LocalMachine\My. Which store is appropriate depends on who or what performs the signing and how the private key is provisioned.

When several certificates exist, selecting by subject name alone can be unreliable. Thumbprint, certificate validity, intended usage and private-key availability are useful attributes to inspect before selecting a certificate for a release operation.

Property Why inspect it PowerShell signing relevance
Subject Identifies the entity represented by the certificate. Useful when distinguishing certificates belonging to different publishers or environments.
Thumbprint Provides a practical identifier for a specific certificate. Useful when automated workflows need deterministic certificate selection.
Enhanced Key Usage Indicates intended certificate usage. Helps confirm that the certificate is appropriate for code signing.
Private key Determines whether the certificate can actually participate in signing. A public certificate without the corresponding private key cannot perform the signing operation.
Validity Shows the certificate's normal validity period. Important when planning current signing and certificate lifecycle operations.

How to verify a PowerShell signature

Get-AuthenticodeSignature provides a practical way to inspect the Authenticode signature associated with a file. It is useful both for manual troubleshooting and for automated release validation.

The returned information should be interpreted as a set of related signals. The status tells you the high-level verification result, while the signer certificate provides additional information about the certificate and signing identity.

A good release process should verify the actual artifact that will be distributed. Checking the certificate before signing is not enough because the final file could be changed, corrupted or otherwise altered after the signing operation.

Get-AuthenticodeSignature
  .\Deploy-App.ps1

# Inspect the resulting object
$signature.Status
$signature.SignerCertificate
Status Conceptual meaning What to investigate
Valid The signature successfully verifies in the current environment. Continue checking certificate, timestamp and policy requirements relevant to the release.
NotSigned No usable signature is present on the file. Confirm that the intended signing operation actually modified the final script.
HashMismatch The signed content no longer matches the signature. Check whether the script was edited, transformed or modified after signing.
NotTrusted Required certificate trust cannot be established. Inspect certificate chain, trusted roots, publisher trust and enterprise configuration.
UnknownError Another verification problem occurred. Inspect the certificate, environment, chain and PowerShell version before assuming the signing key is the problem.

What happens if a signed PowerShell script is modified?

The most important integrity property of script signing is that the signature is tied to the signed content. When relevant content changes, the content represented by the signature no longer corresponds to the modified file.

This can happen through obvious manual editing, but automated deployment systems can cause the same problem if they transform, rewrite or otherwise modify a script after signing.

01

Original

Final script is prepared.

02

Sign

Authenticode signature is created.

03

Modify

Script content changes.

04

Recalculate

Verification sees different signed content.

05

Mismatch

Signature no longer matches.

06

Verify

PowerShell can report failure.

07

Re-sign

Modify, save and sign again.

Release rule

The correct sequence is generally modify → save → test → sign → verify → distribute. The risky sequence is sign → modify → distribute, because the distributed script may no longer validate against its signature.

How PowerShell identifies the signer

PowerShell can obtain signer information from the certificate associated with a valid Authenticode signature. The certificate subject provides the identity information that can be presented to users or inspected by administrators.

This identity should not be confused with trust. A certificate can contain a recognizable publisher name while the local environment still cannot establish the required trust relationship.

Trust can depend on the certificate chain, trusted root certificates, trusted publisher configuration and enterprise security policy. In other words, "who signed this?" and "do I trust this signer here?" are related but different questions.

PowerShell script

Deploy-App.ps1 contains the signing information that PowerShell can inspect.

→

Signer certificate

The certificate identifies the signer and supplies the public key used during signature validation.

→

Publisher trust

The certificate and its chain are evaluated against the relevant trust configuration.

Trusted publishers in PowerShell

A trusted publisher is not simply a name displayed beside a script. Publisher trust is connected to the signer certificate and the trust configuration in the environment where the script is being evaluated.

Users may encounter publisher-trust decisions when PowerShell evaluates signed scripts. Administrators can also encounter these decisions when designing enterprise trust stores and certificate deployment processes.

In an organization, the trust model may involve centrally managed certificate stores, enterprise policy and controlled publisher certificates. This allows an organization to define which signing identities it recognizes rather than assuming that every valid certificate should automatically be trusted for every internal task.

Trust context

Four things can influence the decision

Signer identity: Which certificate signed the script?

Certificate chain: Can the certificate path be established?

Trusted publishers: Does the environment recognize the signer as trusted?

Enterprise policy: Are additional organization controls applied?

PowerShell code signing and timestamping

Timestamping adds information associated with when a signature was created. This becomes useful when a signed script needs to be evaluated after the certificate used for signing has reached the end of its normal validity period.

A timestamp doesn't repair a broken signature and doesn't protect a script from later modification. It provides signing-time evidence that can be considered during historical signature evaluation.

Script finalized Release candidate
Signature created Private key used
Timestamp added Signing-time evidence
Certificate expires Later lifecycle event
Historical evaluation Timestamp can matter

What happens when a PowerShell signing certificate expires?

Certificate expiration affects the certificate's normal validity period, but it should not be treated as a simple statement that every script ever signed by that certificate instantly becomes equivalent to an unsigned file.

New scripts should normally be signed with an appropriate current certificate. Existing scripts require a separate historical verification analysis, where timestamp information and certificate status can become important.

This is also why certificate lifecycle planning should happen before the certificate reaches expiration. A replacement certificate needs to be available for new signing operations, while existing signed scripts should be tested under the environments where they are expected to run.

What Happens When a Code Signing Certificate Expires? →
Do not confuse

Expiration is different from revocation

Expiration means the certificate has reached the end of its normal validity period.

Revocation means the issuing authority has withdrawn the certificate's trust status.

These events can have different consequences for current and historical signature evaluation.

What happens if a PowerShell signing certificate is revoked?

Revocation is more serious than ordinary certificate expiration because it represents an explicit withdrawal of the certificate's trust status. The reasons can include key compromise, incorrect issuance or other certificate-security events.

A revoked certificate can affect signature verification depending on the verification environment, certificate-status information available to the system and the historical context of the signature.

Organizations should therefore have a response plan that covers replacement certificates, affected scripts, build pipelines, signing infrastructure and trust configuration. The right response depends on why the certificate was revoked and whether the associated private key may have been compromised.

01

Detect

Identify certificate-status change.

02

Assess

Determine affected scripts and keys.

03

Contain

Stop unauthorized signing activity.

04

Replace

Establish a new signing identity.

05

Re-sign

Sign current release scripts.

06

Verify

Test signatures and trust.

07

Document

Record the incident and response.

PowerShell code signing with CI/CD

PowerShell scripts are frequently used in deployment, infrastructure, configuration and release automation. In these environments, signing should be treated as a controlled release operation rather than a manual step performed on a developer workstation.

A typical pipeline builds or retrieves the final script, runs required tests, requests a signing operation, timestamps the signature, verifies the resulting artifact and then publishes or deploys it.

The security challenge is the signing key. Build agents and service accounts should receive only the access they need to request signing. The private key itself should remain protected according to the organization's risk requirements.

Source control
→
Build
→
Protected signing
→
Verify
→
Publish / Deploy
01 / ACCESS

Control certificate access

Give signing permissions only to the pipeline or service identities that require them.

02 / SECRETS

Protect signing credentials

Don't place private-key material in source control, ordinary build variables or unrestricted developer environments.

03 / VERIFICATION

Verify the release artifact

Check the actual signed script before publishing it to the next stage.

04 / AUDIT

Keep signing activity visible

Record which pipeline or service requested signing and which release artifact was produced.

PowerShell code signing with an HSM

A hardware security module can keep a signing private key inside a protected cryptographic environment instead of treating it as an ordinary exportable file on a build machine.

The PowerShell signing process can request a cryptographic operation through the configured signing infrastructure while the underlying private key remains protected. This separation becomes increasingly valuable when many automated jobs can produce production scripts.

HSM protection doesn't automatically make a signing environment secure. Authentication, authorization, certificate management, pipeline controls and audit logging still matter.

PowerShell
/ CI agent
→
Signing request
→
HSM
Protected key
→
Signature
→
Signed .ps1

PowerShell code signing with cloud signing

Cloud signing changes where the signing key is protected and how the signing operation is requested. Instead of placing a private key directly on a build machine, the PowerShell or CI/CD environment can authenticate to a controlled signing service.

The service can enforce authentication, authorization and signing policy before performing the cryptographic operation with a protected key.

"Cloud" should not be treated as a security guarantee by itself. The important controls are the protection of the private key, the identity requesting the signature, permissions around that identity, signing policy and auditability.

PowerShell / Build environment
↓
Authentication + authorization
↓
Cloud signing service
↓
Protected private key
↓
Signed PowerShell script

PowerShell script signing in enterprise environments

Enterprise PowerShell environments often contain a large number of administrative and automation scripts. Signing becomes more valuable when scripts move beyond an individual administrator's workstation and become part of controlled operational processes.

An enterprise signing model can combine execution policy, trusted publishers, enterprise certificate trust, centralized signing, CI/CD pipelines and certificate lifecycle management. The objective is not simply to sign every file, but to establish a repeatable chain from source-controlled script to verified deployment.

Developer
→
Source control
→
Review / build
→
Signing service
→
Enterprise deployment
POLICY

Execution policy

Define the PowerShell execution behavior expected across managed systems.

TRUST

Certificate trust

Ensure managed systems can establish trust for the organization's approved signing certificates.

SIGNING

Centralized signing

Keep production signing under controlled infrastructure rather than distributing private keys to every administrator.

LIFECYCLE

Certificate management

Plan renewals, replacements, expiration, revocation and incident response before they interrupt automation.

How to build a secure PowerShell signing workflow

A secure workflow makes the signing operation a controlled boundary between development and distribution. The script is reviewed and tested before the signing system is allowed to create the release signature.

The final verification step is equally important. It confirms that the artifact produced by the signing process is actually the artifact that the release system intends to distribute.

01

Source

Keep scripts under version control.

02

Review

Approve changes before release.

03

Build

Prepare the final script.

04

Sign

Use protected signing infrastructure.

05

Timestamp

Add signing-time evidence.

06

Verify

Validate the actual release file.

07

Execute

Run under the target policy.

PowerShell code signing troubleshooting

Troubleshooting becomes much faster when the problem is classified before changing certificates or execution-policy settings. Start with the script and signature, then move through the certificate, trust and policy layers.

In CI/CD environments, also check whether the build agent can access the certificate and private key correctly. A certificate that works interactively on a developer machine may not be available to a service account running an automated signing job.

Layer Common problem What to check
Script Script is unsigned Use Get-AuthenticodeSignature and confirm that the intended release artifact contains a signature.
Script Script changed after signing Check for manual edits, deployment transformations or automated file modifications.
Certificate Wrong certificate Confirm subject, thumbprint, intended usage and certificate selection logic.
Certificate Expired or revoked Inspect certificate status and determine whether a replacement certificate is required.
Certificate Private key unavailable Confirm that the signing identity has access to the corresponding private key.
Certificate Missing Code Signing usage Check the certificate's intended usage and whether it is suitable for the signing operation.
Trust Untrusted publisher Inspect publisher trust and local or enterprise certificate-store configuration.
Trust Chain failure Check root trust, intermediate certificates and certificate-chain construction.
Policy AllSigned blocks script Confirm that the script has a valid signature and that the signer can be trusted in the execution environment.
Policy RemoteSigned behavior Determine whether PowerShell treats the script as originating from a remote source and whether the required signature is present.
Timestamp Timestamp failure Check timestamp configuration, service availability and the resulting signature information.
Environment CI/CD signing failure Confirm certificate-store access, permissions, service identity and protected-key integration on the build agent.

Complete PowerShell signing example

Consider a deployment team releasing Deploy-App.ps1. The script is stored in source control, reviewed and tested before the release process selects the approved code signing certificate.

The signing process creates the Authenticode signature and adds timestamp information. The pipeline then verifies the completed artifact. Only after verification succeeds does the release move to deployment.

01

Deploy-App.ps1

Final script enters release.

02

Certificate

Approved signer selected.

03

Set-AuthenticodeSignature

Signature is created.

04

Timestamp

Signing time recorded.

05

Get-AuthenticodeSignature

Result is inspected.

06

Valid

Signature passes verification.

07

Deploy

Script enters execution environment.

If the script changes

Modify, save and sign again

A developer edits the script after the signature has already been created.

The changed content no longer corresponds to the original signature, so PowerShell can report a signature or hash mismatch.

The correct release action is to test the changed script and create a new signature.

If the certificate is not trusted

Separate signature validity from trust

The script can contain a signature while the execution environment cannot establish the required trust for the signer certificate.

Check the certificate chain, trusted roots, publisher configuration and enterprise trust settings before replacing the script or certificate unnecessarily.

PowerShell code signing best practices

The strongest PowerShell signing workflows combine cryptographic protection with disciplined release processes. The certificate alone isn't the security control. The way the key, script, pipeline and verification process are managed matters just as much.

01

Sign production scripts

Apply signatures to scripts that are distributed into production or other environments where signer identity and integrity matter.

02

Use an appropriate certificate

Confirm that the certificate is intended for code signing and that the correct private key is available to the signing process.

03

Protect the private key

Keep signing keys away from unnecessary developer and build-system access.

04

Timestamp signatures

Use trusted timestamping where appropriate so signing-time evidence is available for later signature evaluation.

05

Verify after signing

Use Get-AuthenticodeSignature or another suitable verification method against the actual release artifact.

06

Don't modify after signing

Make final content changes before signing. If the script changes, sign the new version again.

07

Control trusted publishers

Manage publisher trust deliberately, especially in enterprise environments.

08

Don't treat execution policy as a security boundary

Combine PowerShell policy with application control, endpoint protection and appropriate administrative controls.

09

Prefer protected signing infrastructure

Use HSM or cloud-backed signing when the release process requires stronger separation of private keys from build systems.

10

Audit automated signing

Record signing activity and restrict which pipelines or identities can request production signatures.

PowerShell code signing myths vs reality

These distinctions prevent several common implementation and troubleshooting mistakes.

Myth PowerShell signing is a technology separate from Authenticode.
Reality PowerShell script signing uses the Microsoft Authenticode signing model.
Myth A signed PowerShell script is automatically safe.
Reality Signing establishes signer and integrity information. It doesn't guarantee that the script contains no malicious or vulnerable logic.
Myth AllSigned means only trusted software can ever execute.
Reality AllSigned imposes a signing requirement, but execution policy isn't a complete security boundary.
Myth A valid signature automatically means the publisher is trusted.
Reality Signature validity and publisher trust are related but distinct verification questions.
Myth Editing a signed script won't affect the signature.
Reality Changes to relevant signed content can cause the signature to fail verification.
Myth The certificate contains the private signing key.
Reality The certificate provides public-key and identity information. The private key should remain protected.
Myth Execution policy replaces code signing.
Reality Execution policy and code signing interact, but they perform different functions.
Myth Timestamping prevents script modification.
Reality Timestamping provides signing-time evidence. It doesn't prevent later changes or repair a broken signature.
Myth Expiration and revocation are the same.
Reality Expiration ends the certificate's normal validity period. Revocation represents withdrawal of certificate trust.

PowerShell code signing FAQ

Answers to the most common questions about signing, verifying and running signed PowerShell scripts.

What is PowerShell code signing?

PowerShell code signing is the process of digitally signing a PowerShell script so it can be associated with a signing identity and its signed content can be checked for changes. PowerShell can inspect the resulting Authenticode signature and certificate information.

What certificate is required to sign a PowerShell script?

A certificate suitable for code signing is required, together with access to the corresponding private key for the signing operation. The exact certificate provisioning method depends on the signing environment.

Does PowerShell use Authenticode?

Yes. PowerShell script signing uses the Microsoft Authenticode signing model. Authenticode is the Windows signing technology, while PowerShell provides the script-specific signing and verification behavior.

How do I sign a PowerShell script?

PowerShell provides the Set-AuthenticodeSignature cmdlet. A typical workflow selects a suitable code signing certificate, signs the final script, optionally timestamps the signature and then verifies the resulting file.

How do I verify a PowerShell signature?

Use Get-AuthenticodeSignature against the script and inspect the returned status and signer certificate information. Further investigation may include certificate validity, chain, publisher trust and timestamp information.

What does Get-AuthenticodeSignature do?

It retrieves information about the Authenticode signature associated with a file, including the signature status and signer certificate information that can be used for inspection and troubleshooting.

What does Set-AuthenticodeSignature do?

It applies an Authenticode digital signature to a supported file using a specified certificate and its associated signing key. It can also work with timestamp information when configured.

Why does PowerShell say the file is not digitally signed?

The script may not contain a signature, the signature may not be usable, or the effective execution policy may require signing that the script does not satisfy. Check the signature status first, then investigate certificate and policy configuration.

What does HashMismatch mean?

A hash mismatch indicates that the content represented by the signature no longer matches the current file. Common causes include editing the script or an automated process changing the file after signing.

How does execution policy affect signed scripts?

Execution policy determines how PowerShell treats scripts under the effective policy. Policies such as AllSigned and RemoteSigned have specific signing-related behavior, while less restrictive policies impose different requirements.

What is the difference between AllSigned and RemoteSigned?

AllSigned requires scripts to be digitally signed under its policy behavior. RemoteSigned generally requires downloaded or remote scripts to have a trusted signature while treating locally created scripts differently.

Can a signed PowerShell script still contain malware?

Yes. A valid signature does not prove that a script is safe. It provides information about the signer and integrity of the signed content, not a guarantee about the script's intent or security.

What happens when a PowerShell signing certificate expires?

New scripts should normally be signed with an appropriate current certificate. Existing signed scripts are a separate verification question, where timestamp and historical signing information can become relevant.

What happens if the PowerShell signing certificate is revoked?

Revocation indicates that the issuing authority has withdrawn the certificate's trust status. The effect on signature evaluation depends on certificate status, verification environment and the historical context of the signature.

Should PowerShell scripts be timestamped?

Timestamping is useful when scripts need signing-time evidence for later historical verification. It does not prevent script changes after signing.

Can PowerShell signing use an HSM?

A protected HSM-based signing architecture can keep the private key inside a controlled cryptographic environment while authorized signing processes request signatures.

Can PowerShell signing be automated in CI/CD?

Yes. Signing can be integrated into automated release pipelines after the final script has been built and tested. The signing key and signing permissions should be protected and the resulting artifact should be verified before deployment.

How should PowerShell signing work in an enterprise?

A controlled enterprise workflow can combine source control, review, execution policy, trusted publisher configuration, certificate trust, protected signing infrastructure, timestamping and post-signing verification.

Sign the script, verify the signature, control the execution environment

PowerShell code signing works best when signing identity, file integrity, certificate trust, timestamping and execution policy are treated as connected but separate parts of the release process.

Explore Code Signing Solutions →