Script-Signing Errors: Troubleshooting Guide

A PowerShell script can fail because it is unsigned, its signature no longer matches the file, its certificate is not trusted, or PowerShell policy blocks execution. Diagnose those layers separately instead of treating every signing error as a certificate problem.

Core diagnostic model: Script → Signature → Certificate → Private Key → Certificate Chain → Timestamp → Windows/PowerShell Policy → Trust. A signature can be cryptographically valid while execution is still blocked by policy or trust configuration.

Common PowerShell Script-Signing Failures

Start by locating the failure stage. The same PowerShell message can lead to very different fixes depending on whether the script has no signature, the signed content changed, the signer is untrusted, or an execution policy is preventing execution.

Script cannot be signed

Look for certificate selection, private-key access, certificate-store, file-access, and timestamping problems.

Signature is invalid

Check whether the file changed after signing, whether the signature is corrupted, or whether the signing operation was incomplete.

Certificate is not trusted

Inspect the signer certificate, intermediate and root certificates, and the trust configuration of the machine or user.

PowerShell blocks execution

Check effective execution policy, Group Policy, file origin, and the signer trust decision before changing policy settings.

Certificate expired or revoked

Separate expiration before signing from expiration after signing, and consider timestamp evidence for older signatures.

CI/CD signing fails

Compare the build agent with the working machine: identity, private key, certificate store, service account, policy, and final artifact.

How to Diagnose a Script-Signing Problem

Use the same sequence for local development, deployment servers, and CI/CD. The objective is to move from a broad error such as “script won't run” to the exact property that failed.

Signed?Check signature presence
Valid?Check integrity
Signer?Inspect certificate
Trusted?Check chain
Timestamp?Inspect signing time
Policy?Find effective policy
Origin?Check downloaded-file context
Important: signature verification and execution-policy enforcement are separate checks. Do not “fix” a valid signature by changing PowerShell policy until you know that policy is actually the failing layer.

“File Is Not Digitally Signed”

This message commonly appears when PowerShell attempts to execute a script under a policy that requires a recognized signature. First establish what is actually on disk. The file may be unsigned, the signature may have been removed, or the file being executed may not be the file that was originally signed.

Check signature presence

Use PowerShell's Authenticode inspection rather than assuming the file has the expected signature. For the signing steps themselves, see how to sign PowerShell scripts after the content is finalized.

Get-AuthenticodeSignature .\Deploy.ps1
  • NotSigned means no recognized Authenticode signature is present.
  • HashMismatch points to a content-integrity problem, not simply missing trust.
  • NotTrusted means the signature and signer need a trust investigation.

Do not collapse different failures

An unsigned script, an invalid signature, an untrusted signer, and a restrictive execution policy are different conditions. Each requires a different diagnostic path.

Unsigned→Sign→Verify
Valid→Trust→Policy

Invalid Signature and Post-Signing Modification

An Authenticode signature covers the signed content. If the script changes after signing, verification can detect that the content no longer matches the signed state. A tiny edit can be enough to invalidate the signature.

Common causes of HashMismatch

  • Opening and saving the script after signing
  • Changing line endings or encoding
  • Template substitution during deployment
  • Adding configuration during packaging
  • CI/CD transformations
  • File corruption or an incomplete transfer

Correct production order

Finalize script→Sign→Timestamp
Verify→Publish

Anything that changes the signed script belongs before signing. If deployment must transform the file, the transformed result needs to become the artifact that is signed and verified.

Certificate and Private-Key Problems

Certificate discovery and private-key availability are related but not interchangeable. A certificate can appear in a certificate store while the corresponding private key is missing or inaccessible. The certificate identifies the signer; the private key is what permits the signing operation.

Certificate available

  • Certificate is installed in the expected store
  • Certificate is suitable for the intended signing purpose
  • Certificate is not expired or otherwise unusable
  • Signer information can be inspected

Private key available

  • Certificate has an associated private key
  • Current user or service account can access it
  • Keychain/store permissions allow signing
  • HSM or cloud provider access works when used
# Inspect certificates available to the current user Get-ChildItem Cert:\CurrentUser\My

If the certificate is visible but signing fails, investigate the key association and access path before replacing the certificate.

Choose a certificate for PowerShell script signing

If your release process requires Authenticode signatures for PowerShell scripts, review the certificate option designed for this signing workflow.

View PowerShell Code Signing Certificates

Set-AuthenticodeSignature Errors

Set-AuthenticodeSignature performs the signing operation, so failures at this stage are usually different from errors reported later when a script is executed. Diagnose the certificate object, private key, file access, timestamp service, and execution environment separately.

SymptomLikely areaWhat to inspect firstVerification
Certificate cannot be selectedCertificate storeCertificate location, purpose, expirationConfirm expected certificate is available
Signing operation failsPrivate keyKey association and access permissionsConfirm the signing identity can create a signature
File cannot be signedFile accessPath, permissions, file lockSign the exact intended file
Timestamping failsTimestamp serviceTSA URL, connectivity, response, trustVerify the resulting signature includes expected timestamp evidence
Works interactively but not in CIEnvironmentAccount, store, key provider, policyRun the same inspection under the build identity

Get-AuthenticodeSignature Status Explained

This command is one of the most useful starting points because it separates signature status from the later question of whether PowerShell will execute the script under its current policy.

StatusWhat it tells youWhat to check next
ValidThe signature is reported as valid for the inspected file.Check signer trust, execution policy, file origin, and any higher-level controls.
NotSignedNo recognized Authenticode signature is present.Confirm the correct file is being executed and sign the finalized artifact if signing is required.
HashMismatchThe signed content no longer matches the file being verified.Find edits, encoding changes, deployment transformations, or corruption.
NotTrustedThe signer or certificate chain is not trusted in the current environment.Inspect the signer certificate, intermediates, root, and trust stores.
UnknownErrorThe signature could not be evaluated normally.Inspect the file, signature structure, certificate, provider, and environment.
NotSupportedFileFormatThe inspected file is not supported for this Authenticode operation.Confirm the file type and use the appropriate signing or verification method.

Certificate Chain and Trust Errors

A valid signature does not automatically mean the signer is trusted. The certificate chain provides the path from the signer certificate through any intermediate CA to a trusted root. The current machine or user environment can affect whether that chain is trusted.

Signer certificate→Intermediate CA→Root CA
  • Check for a missing intermediate certificate.
  • Check whether the root is trusted in the current environment.
  • Compare trust stores when the same script behaves differently on two computers.
  • Consider enterprise or private CA configuration separately from public CA trust.
Keep these three questions separate: Is the signature valid? Is the signer certificate valid? Is the signer trusted here? A “NotTrusted” result should not be treated as proof that the file was modified.

Expired and Revoked Code Signing Certificates

Expired before signing

A certificate that is already expired is not the same situation as a certificate that expires after a signature was created.

Expired after signing

Timestamp evidence can provide important signing-time context when an older signature is evaluated after the certificate's validity period has ended. The exact validation result depends on the platform and certificate status available to the verifier.

Revoked certificate

Revocation is a different lifecycle event from expiration. It can indicate that a certificate should no longer be trusted, including situations involving key compromise. Review what happens when a code signing certificate is revoked for the broader lifecycle implications.

  • Determine whether the certificate was revoked and why.
  • Check the signing time and timestamp evidence.
  • Assess the impact on new signing and previously distributed scripts.
  • Replace affected signing credentials where required.

For broader lifecycle decisions, use the site's dedicated certificate expiration and revocation resources rather than treating this troubleshooting page as a complete certificate-lifecycle guide.

Timestamp Errors

Timestamping adds evidence about when a signature was created. In production script signing, it should be treated as part of the signing workflow rather than an optional afterthought.

Service unavailable

The timestamp server may be unreachable or temporarily unavailable. Check network access and the configured TSA endpoint.

Invalid response

A malformed or unusable timestamp response can cause signing to succeed only partially or fail at the timestamp stage.

Timestamp trust

Inspect the timestamp certificate and chain when older signatures depend on timestamp evidence for validation.

# Example structure only. Replace TIMESTAMP_URL with your approved TSA. Set-AuthenticodeSignature .\Deploy.ps1 $cert -TimestampServer TIMESTAMP_URL

Execution Policy Errors

PowerShell execution policy is the major PowerShell-specific layer in this troubleshooting model. It controls how PowerShell handles script execution. It does not replace Authenticode signing, and it should not be presented as a complete security boundary.

Restricted

Script execution is restricted. A signing problem is not the right diagnosis if policy prevents scripts from running in the first place.

AllSigned

Scripts generally need a recognized digital signature. A signed file can still fail if its signer is not accepted or its signature is invalid.

RemoteSigned

Downloaded scripts can receive different treatment from locally created scripts, particularly when Windows records their remote origin.

Unrestricted

Execution restrictions are reduced, but file-origin and warning behavior can still matter.

Bypass

Policy checks are bypassed for the relevant invocation or scope. It should not be used as a default troubleshooting fix.

Undefined

No policy is explicitly set at that scope. Another scope or system configuration can still determine the effective behavior.

Get-ExecutionPolicy -List

Check the full policy list before changing anything. Pay attention to machine policy, user policy, local machine, current user, and process scope, because the effective policy can be determined by a higher-priority setting.

“Running Scripts Is Disabled on This System”

Do not immediately change the execution policy. First determine which policy is active and whether Group Policy or another higher-priority configuration controls it.

Inspect the effective configuration

Get-ExecutionPolicy
Get-ExecutionPolicy -List
  • Identify the effective policy.
  • Compare user and machine scopes.
  • Check whether Group Policy is involved.
  • Confirm the expected script path and file.

Then inspect the signature

Get-AuthenticodeSignature .\Deploy.ps1

If the signature reports Valid but PowerShell still refuses execution, the next investigation is policy, signer trust, file origin, or another environment-specific control.

AllSigned Errors

AllSigned makes the distinction between “the script is signed” and “PowerShell accepts the signature” especially visible. A script can be signed yet still be blocked if the signature is invalid, the signer is not trusted, or the certificate is not acceptable in the current environment.

ConditionWhat to investigate
Unsigned scriptConfirm the file and add a signature to the finalized script when signing is required.
Invalid signatureCheck for post-signing edits, encoding changes, and deployment transformations.
Signer not trustedInspect the signer certificate and certificate chain in the current trust environment.
Certificate invalidCheck validity, revocation status, intended use, and certificate configuration.
Signed and valid but still blockedCheck effective policy, Group Policy, file origin, and the exact PowerShell environment.

RemoteSigned and Downloaded Scripts

RemoteSigned introduces file-origin context into the troubleshooting process. A script created locally can behave differently after it is downloaded because Windows can record that the file originated from the internet.

Compare the file context

  • Was the script downloaded or created locally?
  • Does Windows have Internet-origin metadata associated with it?
  • Was the file copied, extracted, or transformed after download?
  • Is the signed file the same artifact that PowerShell is executing?

Do not confuse origin with signature

File origin, signature validity, signer trust, and execution policy are separate properties. A downloaded script can have a valid signature while still receiving policy treatment different from a locally created file.

Trusted Publisher Problems

“Trusted publisher” describes a trust decision associated with the signer identity. It is not simply another name for a valid signature.

Valid signature

The signature matches the signed content and can be cryptographically verified.

Valid certificate

The signer certificate itself passes the relevant validity checks.

Trusted publisher

The current environment accepts the signer or certificate chain for the operation being performed.

Enterprise environments can deliberately establish publisher or certificate trust. When a script works for one user but not another, compare certificate stores and policy configuration rather than re-signing the same file without evidence that the signature itself is wrong.

Review Windows signing certificate options

For scripts and other Windows software, choose a certificate that fits the artifact and signing process you need to support.

Explore Windows Code Signing Certificates

Script Signing Works on One Computer but Not Another

When the same signed script behaves differently, compare the environments systematically. The file may be identical while trust and policy state are not.

ComparisonComputer AComputer BWhy it matters
PowerShell versionRecord versionRecord versionBehavior and supported features can differ.
Execution policyRecord all scopesRecord all scopesPolicy can block an otherwise valid signature.
Certificate trustInspect chainInspect chainDifferent trust stores can produce different results.
User accountRecord accountRecord accountCertificate stores and permissions can be user-specific.
Group PolicyCheckCheckEnterprise policy can override local assumptions.
File artifactCompare hash/fileCompare hash/fileA transformed or different script is a different verification target.
File originCheck metadataCheck metadataRemote-origin context can affect execution behavior.

Script Signing in CI/CD

CI/CD failures often come from environmental differences rather than from the script itself. A developer can sign interactively because the certificate, private key, and user profile are available, while a build agent runs under a service identity with none of those assumptions.

Generate→Finalize→Sign→Timestamp→Verify→Publish

Build-agent checks

  • Certificate is available to the build identity.
  • Private key is accessible through the approved provider.
  • Service account has required permissions.
  • Certificate store is the expected store.
  • Timestamp service is reachable.

Artifact checks

  • Signing happens after final script generation.
  • No deployment step changes the signed file.
  • Signature status is checked before publication.
  • The published artifact is the verified artifact.
  • Execution is tested in the target environment.

HSM and Cloud Signing Troubleshooting

Hardware-protected and cloud-based signing can improve key protection, but they add another access layer. A visible certificate does not prove that the current build identity can reach the signing key.

Authentication

Confirm the CI identity is authenticated with the signing provider and has the expected permissions.

Provider access

Check provider configuration, network/API connectivity, key availability, and signing permissions.

Final verification

Inspect the completed script after signing and timestamping. A successful signing API call is not the final verification step.

Script-Signing Errors by Cause

SymptomLikely layerFirst check
File is not digitally signedSignatureIs the exact script signed?
NotSignedSignatureSignature presence
HashMismatchIntegrityWas the script modified?
NotTrustedTrustCertificate chain and trust store
Certificate not foundCertificateCertificate store and purpose
Private key unavailableKeyCertificate/key association and access
Execution blockedPolicyEffective execution policy
AllSigned blocks scriptPolicy/trustSignature plus signer trust
Timestamp failedTimestampTSA configuration and connectivity
Works locally, fails in CIEnvironmentCertificate, key, account, policy, artifact

Diagnose PowerShell Signing Errors in the Right Order

When PowerShell refuses a script, use this sequence before changing policy or issuing a new certificate.

PowerShell refuses script→Get-AuthenticodeSignature→NotSigned?→HashMismatch?
NotTrusted?→Valid?→Execution policy→File origin / Group Policy

NotSigned

Confirm the correct script and signing workflow. Do not troubleshoot certificate trust until a signature exists.

HashMismatch

Find the process that changed the script after signing. Re-sign only after the final content is known.

NotTrusted

Inspect the signer certificate and chain in the environment where the script is being executed.

Valid signature but still blocked

Move to execution policy, Group Policy, file-origin metadata, PowerShell version, and environment-specific controls. This is the point where repeatedly re-signing the script is unlikely to solve the actual problem.

Example: A Valid Signature That PowerShell Still Blocks

Scenario: A PowerShell script is signed and reports Valid, but it still will not execute.

Investigation

  1. Verify the signature on the exact script.
  2. Inspect the signer certificate.
  3. Check certificate trust and chain.
  4. Inspect the effective execution policy.
  5. Check whether Group Policy overrides local settings.

Continue

  1. Check whether the script has remote-origin metadata.
  2. Determine whether the failure is signing or PowerShell policy.
  3. Fix only the layer that failed.
  4. Verify execution again.

The useful conclusion may be that nothing is wrong with the signature. A policy or trust condition can block a correctly signed script, which is why the diagnostic sequence matters.

Prevent Script-Signing Failures Before Release

Before signing

  • Finalize the script.
  • Use an appropriate signing certificate.
  • Protect the private key.
  • Document the intended signing environment.

During release

  • Timestamp production signatures.
  • Verify with Get-AuthenticodeSignature.
  • Do not transform signed scripts.
  • Publish the verified artifact.

After release

  • Test in the target environment.
  • Control trusted publishers.
  • Secure CI/CD signing access.
  • Monitor certificate expiration and revocation.

Frequently Asked Questions About Script Signing

Why does PowerShell say my script is not digitally signed?
Usually the script has no recognized Authenticode signature, or the signature is not recognized in the current environment. Check the exact file with Get-AuthenticodeSignature before changing execution policy.
Why does Get-AuthenticodeSignature show HashMismatch?
The content being verified no longer matches the content covered by the signature. Look for edits, encoding or line-ending changes, deployment transformations, or file corruption after signing.
Why is my signed script NotTrusted?
The signature can be valid while the signer or certificate chain is not trusted in the current environment. Inspect the signer certificate, intermediate certificates, root trust, and enterprise trust configuration.
Why does Set-AuthenticodeSignature fail?
Check the certificate object, private-key association and access, file permissions, signing environment, and timestamp service. The failure is at the signing stage, so execution policy may not be relevant yet.
Why does a signed script work on one computer but not another?
Compare PowerShell versions, effective execution policy, certificate stores, trust chains, user accounts, Group Policy, file-origin metadata, and the exact script artifact.
Why does AllSigned block my signed script?
A signature alone is not the whole decision. Check signature validity, signer trust, certificate validity, and the effective policy that applies to the current environment.
Why does RemoteSigned block my script?
Check whether the file has remote-origin metadata and whether the downloaded artifact is the same signed file you intended to execute.
Does a PowerShell script need a code signing certificate?
That depends on the signing requirement and execution environment. Where Authenticode signing is required, the signing certificate and corresponding private key are used to create the script signature.
Can an expired certificate still validate a signed script?
Expiration before signing is different from expiration after signing. Timestamp evidence can provide important signing-time context for older signatures, but the final result depends on certificate status and the verification environment.
Why does changing a script after signing break the signature?
The signature is tied to the signed content. Changes to the script can make the content no longer match what was signed, producing an integrity-related failure such as HashMismatch.
How do I check whether a PowerShell script is signed?
Run Get-AuthenticodeSignature .\YourScript.ps1 and inspect the status, signer certificate, and timestamp information.
How do I troubleshoot script signing in CI/CD?
Compare the build agent with the working environment, including certificate availability, private-key access, service-account permissions, certificate store, signing provider, timestamp service, execution policy, and the final signed artifact.

Related PowerShell and Code Signing Resources

PowerShell Code Signing

How PowerShell signing works, including signing commands, execution policy, release workflow, and CI/CD.

Windows Code Signing Troubleshooting

Broader Windows signing diagnostics covering certificates, SignTool, trust, SmartScreen, and release environments.

Authenticode Errors

Troubleshooting for Authenticode verification, certificate trust, and signing failures.

Compare available code signing certificates

Compare certificate options for your publisher identity and signing environment before standardizing a production workflow.

Browse All Code Signing Certificates