11---
22description : Explains how to sign scripts so that they comply with the PowerShell execution policies.
33Locale : en-US
4- ms.date : 10/23/2023
4+ ms.date : 01/07/2025
55online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_signing?view=powershell-5.1&WT.mc_id=ps-gethelp
66schema : 2.0.0
77title : about_Signing
@@ -33,33 +33,39 @@ PowerShell checks the Authenticode signature of the following type types:
3333- ` .xaml ` XAML script files
3434
3535For more information about PowerShell execution policies, see
36- [ about_Execution_Policies] [ 01 ] .
36+ [ about_Execution_Policies] [ 03 ] .
3737
38- ## To permit signed scripts to run
38+ ## Permit the execution of signed scripts
3939
4040When you start PowerShell on a computer for the first time, the ** Restricted**
4141execution policy, which is the default, is likely to be in effect.
4242
43- The ** Restricted** policy doesn't permit any scripts to run .
43+ The ** Restricted** policy prevents all scripts from running .
4444
4545To find the effective execution policy on your computer, type:
4646
4747``` powershell
4848Get-ExecutionPolicy
4949```
5050
51- To run unsigned scripts that you write on your local computer and signed
52- scripts from other users, start PowerShell with the ** Run as Administrator **
53- option and then use the following command to change the execution policy on the
54- computer to ** RemoteSigned ** :
51+ The ** RemoteSigned ** policy allows you to run signed scripts or unsigned
52+ scripts that you create locally. To configure this policy, start PowerShell
53+ with the ** Run as Administrator ** option and then use the following command to
54+ change the execution policy.
5555
5656``` powershell
5757Set-ExecutionPolicy RemoteSigned
5858```
5959
6060For more information, see the help topic for the ` Set-ExecutionPolicy ` cmdlet.
6161
62- ## Running unsigned scripts using the RemoteSigned execution policy
62+ To run a signed script, the script must have a digital signature from a trusted
63+ publisher. The code signing certificate must be issued by a certification
64+ must be issued by a certification authority that is trusted on the computer.
65+ Self-signed certificates must be installed in the ** Trusted Root Certificates**
66+ store on the computer.
67+
68+ ## Run unsigned scripts using the RemoteSigned policy
6369
6470If your PowerShell execution policy is ** RemoteSigned** , PowerShell won't run
6571unsigned scripts that are downloaded from the internet, including unsigned
@@ -85,7 +91,7 @@ procedure.
85911 . Right-click the script file, and then click ** Properties** .
86921 . Click ** Unblock** .
8793
88- If a script that was downloaded from the internet is digitally signed, but you
94+ If a script that you downloaded from the internet is digitally signed, but you
8995haven't yet chosen to trust its publisher, PowerShell displays the following
9096message:
9197
@@ -110,10 +116,8 @@ You can sign the scripts that you write and the scripts that you get from other
110116sources. Before you sign any script, examine each command to verify that it's
111117safe to run.
112118
113- For best practices about code signing, see [ Code-Signing Best Practices] [ 02 ] .
114-
115119For more information about how to sign a script file, see
116- [ Set-AuthenticodeSignature] [ 03 ] .
120+ [ Set-AuthenticodeSignature] [ 06 ] .
117121
118122The ` New-SelfSignedCertificate ` cmdlet, introduced in the PKI module in
119123PowerShell 3.0, creates a self-signed certificate that's appropriate for
@@ -136,10 +140,11 @@ certificate. Two types of certificates are suitable for signing a script file:
136140 on your computer. However, a script signed by a self-signed certificate will
137141 not run on other computers.
138142
139- Typically, you would use a self-signed certificate only to sign scripts that
140- you write for your own use and to sign scripts that you get from other sources
141- that you have verified to be safe. It isn't appropriate for scripts that will
142- be shared, even within an enterprise.
143+ Self-signed certificate should only be used to sign scripts for testing
144+ purposes.
145+
146+ It isn't appropriate for scripts that will be shared, even within an
147+ enterprise.
143148
144149If you create a self-signed certificate, be sure to enable strong private key
145150protection on your certificate. This prevents malicious programs from signing
@@ -148,7 +153,7 @@ topic.
148153
149154## Create a self-signed certificate
150155
151- To create a self-signed certificate, use the [ New-SelfSignedCertificate] [ 04 ]
156+ To create a self-signed certificate, use the [ New-SelfSignedCertificate] [ 08 ]
152157cmdlet in the PKI module. This module is introduced in PowerShell 3.0. For more
153158information, see the help topic for the ` New-SelfSignedCertificate ` cmdlet.
154159
@@ -169,7 +174,7 @@ Certificate Creation tool `MakeCert.exe`. This tool is included in the
169174Microsoft .NET SDK (versions 1.1 and later) and in the Microsoft Windows SDK.
170175
171176For more information about the syntax and the parameter descriptions of the
172- ` MakeCert.exe ` tool, see [ Certificate Creation Tool (MakeCert.exe)] [ 05 ] .
177+ ` MakeCert.exe ` tool, see [ Certificate Creation Tool (MakeCert.exe)] [ 01 ] .
173178
174179To use the ` MakeCert.exe ` tool to create a certificate, run the following
175180commands in an SDK Command Prompt window.
@@ -201,7 +206,7 @@ a certificate file in the file system directory.
201206At the PowerShell prompt, type:
202207
203208``` powershell
204- Get-ChildItem cert:\CurrentUser\my -codesigning
209+ Get-ChildItem cert:\CurrentUser\my -CodeSigning
205210```
206211
207212This command uses the PowerShell Certificate provider to view information
@@ -229,10 +234,9 @@ you are using the **AllSigned** execution policy, you must sign the
229234` Add-Signature.ps1 ` script before you run it.
230235
231236> [ !IMPORTANT]
232- > The script must be saved using ASCII or UTF8NoBOM encoding. You can sign a
233- > script file that uses a different encoding, but the script fails to run or
234- > the module containing the script fails to import. The script will also fail
235- > if the file contains Unicode (UTF8) characters.
237+ > Before PowerShell 7.2, the script must be saved using ASCII or UTF8NoBOM
238+ > encoding. PowerShell 7.2 and higher supports signed scripts for any encoding
239+ > format.
236240
237241To use this script, copy the following text into a text file, and name it
238242` Add-Signature.ps1 ` .
@@ -321,19 +325,19 @@ stamp server ensures that users can use your script for many years to come.
321325
322326## See also
323327
324- - [ about_Execution_Policies] [ 01 ]
325- - [ about_Profiles] [ 06 ]
326- - [ Set-AuthenticodeSignature] [ 03 ]
327- - [ Get-ExecutionPolicy] [ 07 ]
328- - [ Set-ExecutionPolicy] [ 08 ]
329- - [ Introduction to Code Signing] [ 09 ]
330-
331- [ 01 ] : about_Execution_Policies.md
332- [ 02 ] : /previous-versions/windows/hardware/design/dn653556 (v=vs.85 )
333- [ 03 ] : xref:Microsoft.PowerShell.Security.Set-AuthenticodeSignature
334- [ 04 ] : xref:pki.New-SelfSignedCertificate
335- [ 05 ] : /previous-versions/dotnet/netframework-2.0/bfsktky3(v=vs.80)
336- [ 06 ] : about_Profiles.md
337- [ 07 ] : xref:Microsoft.PowerShell.Security.Get-ExecutionPolicy
338- [ 08 ] : xref:Microsoft.PowerShell.Security.Set-ExecutionPolicy
339- [ 09 ] : /previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537361(v=vs.85)
328+ - [ about_Execution_Policies] [ 03 ]
329+ - [ about_Profiles] [ 04 ]
330+ - [ Set-AuthenticodeSignature] [ 06 ]
331+ - [ Get-ExecutionPolicy] [ 05 ]
332+ - [ Set-ExecutionPolicy] [ 07 ]
333+ - [ Introduction to Code Signing] [ 02 ]
334+
335+ <!-- link references -->
336+ [ 01 ] : /previous-versions/dotnet/netframework-2.0/bfsktky3 (v=vs.80 )
337+ [ 02 ] : /previous-versions/windows/internet-explorer/ie-developer/platform-apis/ms537361(v=vs.85)
338+ [ 03 ] : about_Execution_Policies.md
339+ [ 04 ] : about_Profiles.md
340+ [ 05 ] : xref:Microsoft.PowerShell.Security.Get-ExecutionPolicy
341+ [ 06 ] : xref:Microsoft.PowerShell.Security.Set-AuthenticodeSignature
342+ [ 07 ] : xref:Microsoft.PowerShell.Security.Set-ExecutionPolicy
343+ [ 08 ] : xref:pki.New-SelfSignedCertificate
0 commit comments