Skip to content

Commit 4a1bfea

Browse files
authored
Merge pull request #11878 from MicrosoftDocs/main
3/7/2025 PM Publish
2 parents 595ff93 + 0dd4558 commit 4a1bfea

File tree

4 files changed

+155
-113
lines changed

4 files changed

+155
-113
lines changed

reference/5.1/Microsoft.PowerShell.Security/Set-AuthenticodeSignature.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ title: Set-AuthenticodeSignature
1111
# Set-AuthenticodeSignature
1212

1313
## SYNOPSIS
14-
Adds an [Authenticode](/windows-hardware/drivers/install/authenticode) signature to a PowerShell
15-
script or other file.
14+
Adds an Authenticode signature to a PowerShell script or other file.
1615

1716
## SYNTAX
1817

@@ -36,8 +35,8 @@ Set-AuthenticodeSignature [-Certificate] <X509Certificate2> [-IncludeChain <Stri
3635

3736
```
3837
Set-AuthenticodeSignature [-Certificate] <X509Certificate2> [-IncludeChain <String>]
39-
[-TimestampServer <String>] [-HashAlgorithm <String>] [-Force] -SourcePathOrExtension <String[]>
40-
-Content <Byte[]> [-WhatIf] [-Confirm] [<CommonParameters>]
38+
[-TimestampServer <String>] [-HashAlgorithm <String>] [-Force] -SourcePathOrExtension
39+
<String[]> -Content <Byte[]> [-WhatIf] [-Confirm] [<CommonParameters>]
4140
```
4241

4342
## DESCRIPTION
@@ -83,7 +82,7 @@ The third command signs the script by splatting the parameters defined in `$sign
8382
> [!NOTE]
8483
> Using the **CodeSigningCert** parameter with `Get-ChildItem` only returns certificates that have
8584
> code-signing authority and contain a private key. If there is no private key, the certificates
86-
> cannot be used for signing.
85+
> can't be used for signing.
8786
8887
### Example 2 - Sign a script using a certificate from a PFX file
8988

@@ -115,7 +114,7 @@ If the certificate file is password protected, PowerShell prompts you for the pa
115114

116115
### Example 3 - Add a signature that includes the root authority
117116

118-
This command adds a digital signature that includes the root authority in the trust chain, and it is
117+
This command adds a digital signature that includes the root authority in the trust chain, and it's
119118
signed by a third-party timestamp server.
120119

121120
```powershell
@@ -129,13 +128,11 @@ $signingParameters = @{
129128
Set-AuthenticodeSignature @signingParameters
130129
```
131130

132-
The first command defines the `$signingParameters` variable as a **HashTable** with the parameters
133-
for the `Set-AuthenticodeSignature` cmdlet to sign the script. It uses the **FilePath** parameter to
134-
specify the path to the script, the **Certificate** parameter to specify that the certificate is
135-
stored in the `$cert` variable, and the **HashAlgorithm** parameter to set the hashing algorithm to
136-
SHA256. It uses the **IncludeChain** parameter to include all of the signatures in the trust chain,
137-
including the root authority. It also uses the **TimeStampServer** parameter to add a timestamp to
138-
the signature. This prevents the script from failing when the certificate expires.
131+
The command uses the **FilePath** parameter to specify the script being signed and the
132+
**Certificate** parameter to specify the certificate that's saved in the `$cert` variable. It uses
133+
the **IncludeChain** parameter to include all of the signatures in the trust chain, including the
134+
root authority. It also uses the **TimeStampServer** parameter to add a timestamp to the signature.
135+
This prevents the script from failing when the certificate expires.
139136

140137
The second command signs the script by splatting the parameters defined in `$signingParameters`.
141138

@@ -147,8 +144,8 @@ Specifies the certificate that will be used to sign the script or file. Enter a
147144
an object representing the certificate or an expression that gets the certificate.
148145

149146
To find a certificate, use `Get-PfxCertificate` or use the `Get-ChildItem` cmdlet in the Certificate
150-
`Cert:` drive. If the certificate is not valid or does not have `code-signing` authority, the
151-
command fails.
147+
`Cert:` drive. If the certificate isn't valid or doesn't have `code-signing` authority, the command
148+
fails.
152149

153150
```yaml
154151
Type: System.Security.Cryptography.X509Certificates.X509Certificate2
@@ -164,8 +161,8 @@ Accept wildcard characters: False
164161
165162
### -Content
166163
167-
This parameter appears in the syntax listing because it is defined in the base class that
168-
`Set-AuthenticodeSignature` is derived from. However, support for this parameter is not implemented
164+
This parameter appears in the syntax listing because it's defined in the base class that
165+
`Set-AuthenticodeSignature` is derived from. However, support for this parameter isn't implemented
169166
in `Set-AuthenticodeSignature`.
170167

171168
```yaml
@@ -182,7 +179,7 @@ Accept wildcard characters: False
182179

183180
### -FilePath
184181

185-
Specifies the path to a file that is being signed.
182+
Specifies the path to a file that's being signed.
186183

187184
```yaml
188185
Type: System.String[]
@@ -199,7 +196,7 @@ Accept wildcard characters: False
199196
### -Force
200197

201198
Allows the cmdlet to append a signature to a read-only file. Even using the **Force** parameter, the
202-
cmdlet cannot override security restrictions.
199+
cmdlet can't override security restrictions.
203200

204201
```yaml
205202
Type: System.Management.Automation.SwitchParameter
@@ -221,7 +218,8 @@ The default is SHA1. Files that are signed with a different hashing algorithm mi
221218
recognized on other systems. Which algorithms are supported depends on the version of the operating
222219
system.
223220

224-
For a list of possible values, see [HashAlgorithmName Struct](/dotnet/api/system.security.cryptography.hashalgorithmname?view=netframework-4.7.2#properties).
221+
For a list of possible values, see
222+
[HashAlgorithmName](xref:System.Security.Cryptography.HashAlgorithmName#properties) struct.
225223

226224
```yaml
227225
Type: System.String
@@ -242,9 +240,10 @@ Determines which certificates in the certificate trust chain are included in the
242240

243241
Valid values are:
244242

245-
- Signer: Includes only the signer's certificate.
246-
- NotRoot: Includes all of the certificates in the certificate chain, except for the root authority.
247-
- All: Includes all the certificates in the certificate chain.
243+
- `Signer`: Includes only the signer's certificate.
244+
- `NotRoot`: Includes all of the certificates in the certificate chain, except for the root
245+
authority.
246+
- `All`: Includes all the certificates in the certificate chain.
248247

249248
```yaml
250249
Type: System.String
@@ -260,8 +259,8 @@ Accept wildcard characters: False
260259

261260
### -LiteralPath
262261

263-
Specifies the path to a file that is being signed. Unlike **FilePath**, the value of the
264-
**LiteralPath** parameter is used exactly as it is typed. No characters are interpreted as
262+
Specifies the path to a file that's being signed. Unlike **FilePath**, the value of the
263+
**LiteralPath** parameter is used exactly as it's typed. No characters are interpreted as
265264
wildcards. If the path includes escape characters, enclose it in single quotation marks. Single
266265
quotation marks tell PowerShell not to interpret any characters as escape sequences.
267266

@@ -279,8 +278,8 @@ Accept wildcard characters: False
279278

280279
### -SourcePathOrExtension
281280

282-
This parameter appears in the syntax listing because it is defined in the base class that
283-
`Set-AuthenticodeSignature` is derived from. However, support for this parameter is not implemented
281+
This parameter appears in the syntax listing because it's defined in the base class that
282+
`Set-AuthenticodeSignature` is derived from. However, support for this parameter isn't implemented
284283
in `Set-AuthenticodeSignature`.
285284

286285
```yaml
@@ -298,7 +297,7 @@ Accept wildcard characters: False
298297
### -TimestampServer
299298

300299
Uses the specified time stamp server to add a time stamp to the signature. Type the URL of the time
301-
stamp server as a string.
300+
stamp server as a string. The URL must start with `http://`.
302301

303302
The time stamp represents the exact time that the certificate was added to the file. A time stamp
304303
prevents the script from failing if the certificate expires because users and programs can verify
@@ -334,7 +333,7 @@ Accept wildcard characters: False
334333

335334
### -WhatIf
336335

337-
Shows what would happen if the cmdlet runs. The cmdlet is not run.
336+
Shows what would happen if the cmdlet runs. The cmdlet isn't run.
338337

339338
```yaml
340339
Type: System.Management.Automation.SwitchParameter
@@ -371,6 +370,8 @@ This cmdlet returns a **Signature** object representing the value it set.
371370

372371
## RELATED LINKS
373372

373+
[Authenticode](/windows-hardware/drivers/install/authenticode)
374+
374375
[Get-AuthenticodeSignature](Get-AuthenticodeSignature.md)
375376

376377
[Get-ExecutionPolicy](Get-ExecutionPolicy.md)

reference/7.4/Microsoft.PowerShell.Security/Set-AuthenticodeSignature.md

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Security.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Security
5-
ms.date: 12/12/2022
5+
ms.date: 03/07/2025
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.security/set-authenticodesignature?view=powershell-7.4&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: Set-AuthenticodeSignature
@@ -11,8 +11,7 @@ title: Set-AuthenticodeSignature
1111
# Set-AuthenticodeSignature
1212

1313
## SYNOPSIS
14-
Adds an [Authenticode](/windows-hardware/drivers/install/authenticode) signature to a PowerShell
15-
script or other file.
14+
Adds an Authenticode signature to a PowerShell script or other file.
1615

1716
## SYNTAX
1817

@@ -36,8 +35,8 @@ Set-AuthenticodeSignature [-Certificate] <X509Certificate2> [-IncludeChain <Stri
3635

3736
```
3837
Set-AuthenticodeSignature [-Certificate] <X509Certificate2> [-IncludeChain <String>]
39-
[-TimestampServer <String>] [-HashAlgorithm <String>] [-Force] -SourcePathOrExtension <String[]>
40-
-Content <Byte[]> [-WhatIf] [-Confirm] [<CommonParameters>]
38+
[-TimestampServer <String>] [-HashAlgorithm <String>] [-Force] -SourcePathOrExtension
39+
<String[]> -Content <Byte[]> [-WhatIf] [-Confirm] [<CommonParameters>]
4140
```
4241

4342
## DESCRIPTION
@@ -59,7 +58,7 @@ These commands retrieve a code-signing certificate from the PowerShell certifica
5958
it to sign a PowerShell script.
6059

6160
```powershell
62-
$cert=Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert
61+
$cert = Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert
6362
Set-AuthenticodeSignature -FilePath PsTestInternet2.ps1 -Certificate $cert
6463
```
6564

@@ -76,7 +75,7 @@ parameter to specify that the certificate is stored in the `$cert` variable.
7675
> [!NOTE]
7776
> Using the **CodeSigningCert** parameter with `Get-ChildItem` only returns certificates that have
7877
> code-signing authority and contain a private key. If there is no private key, the certificates
79-
> cannot be used for signing.
78+
> can't be used for signing.
8079
8180
### Example 2 - Sign a script using a certificate from a PFX file
8281

@@ -88,7 +87,7 @@ $cert = Get-PfxCertificate -FilePath C:\Test\Mysign.pfx
8887
Set-AuthenticodeSignature -FilePath ServerProps.ps1 -Certificate $cert
8988
```
9089

91-
The first command uses the `Get-PfxCertificate` cmdlet to load the C:\Test\MySign.pfx certificate
90+
The first command uses the `Get-PfxCertificate` cmdlet to load the `C:\Test\MySign.pfx` certificate
9291
into the `$cert` variable.
9392

9493
The second command uses `Set-AuthenticodeSignature` to sign the script. The **FilePath** parameter
@@ -99,15 +98,22 @@ If the certificate file is password protected, PowerShell prompts you for the pa
9998

10099
### Example 3 - Add a signature that includes the root authority
101100

102-
This command adds a digital signature that includes the root authority in the trust chain, and it is
101+
This command adds a digital signature that includes the root authority in the trust chain, and it's
103102
signed by a third-party timestamp server.
104103

105104
```powershell
106-
Set-AuthenticodeSignature -FilePath c:\scripts\Remodel.ps1 -Certificate $cert -IncludeChain All -TimestampServer "https://timestamp.fabrikam.com/scripts/timstamper.dll"
105+
$signingParameters = @{
106+
FilePath = 'C:\scripts\Remodel.ps1'
107+
Certificate = $cert
108+
HashAlgorithm = 'SHA256'
109+
IncludeChain = 'All'
110+
TimestampServer = 'http://timestamp.fabrikam.com/scripts/timstamper.dll'
111+
}
112+
Set-AuthenticodeSignature @signingParameters
107113
```
108114

109115
The command uses the **FilePath** parameter to specify the script being signed and the
110-
**Certificate** parameter to specify the certificate that is saved in the `$cert` variable. It uses
116+
**Certificate** parameter to specify the certificate that's saved in the `$cert` variable. It uses
111117
the **IncludeChain** parameter to include all of the signatures in the trust chain, including the
112118
root authority. It also uses the **TimeStampServer** parameter to add a timestamp to the signature.
113119
This prevents the script from failing when the certificate expires.
@@ -120,8 +126,8 @@ Specifies the certificate that will be used to sign the script or file. Enter a
120126
an object representing the certificate or an expression that gets the certificate.
121127

122128
To find a certificate, use `Get-PfxCertificate` or use the `Get-ChildItem` cmdlet in the Certificate
123-
`Cert:` drive. If the certificate is not valid or does not have `code-signing` authority, the
124-
command fails.
129+
`Cert:` drive. If the certificate isn't valid or doesn't have `code-signing` authority, the command
130+
fails.
125131

126132
```yaml
127133
Type: System.Security.Cryptography.X509Certificates.X509Certificate2
@@ -137,8 +143,8 @@ Accept wildcard characters: False
137143
138144
### -Content
139145
140-
This parameter appears in the syntax listing because it is defined in the base class that
141-
`Set-AuthenticodeSignature` is derived from. However, support for this parameter is not implemented
146+
This parameter appears in the syntax listing because it's defined in the base class that
147+
`Set-AuthenticodeSignature` is derived from. However, support for this parameter isn't implemented
142148
in `Set-AuthenticodeSignature`.
143149

144150
```yaml
@@ -155,7 +161,7 @@ Accept wildcard characters: False
155161

156162
### -FilePath
157163

158-
Specifies the path to a file that is being signed.
164+
Specifies the path to a file that's being signed.
159165

160166
```yaml
161167
Type: System.String[]
@@ -172,7 +178,7 @@ Accept wildcard characters: False
172178
### -Force
173179

174180
Allows the cmdlet to append a signature to a read-only file. Even using the **Force** parameter, the
175-
cmdlet cannot override security restrictions.
181+
cmdlet can't override security restrictions.
176182

177183
```yaml
178184
Type: System.Management.Automation.SwitchParameter
@@ -195,7 +201,8 @@ earlier versions, the default is SHA1. Files that are signed with a different ha
195201
might not be recognized on other systems. Which algorithms are supported depends on the version of
196202
the operating system.
197203

198-
For a list of possible values, see [HashAlgorithmName Struct](/dotnet/api/system.security.cryptography.hashalgorithmname?view=netframework-4.7.2#properties).
204+
For a list of possible values, see
205+
[HashAlgorithmName](xref:System.Security.Cryptography.HashAlgorithmName#properties) struct.
199206

200207
```yaml
201208
Type: System.String
@@ -216,9 +223,10 @@ Determines which certificates in the certificate trust chain are included in the
216223

217224
Valid values are:
218225

219-
- Signer: Includes only the signer's certificate.
220-
- NotRoot: Includes all of the certificates in the certificate chain, except for the root authority.
221-
- All: Includes all the certificates in the certificate chain.
226+
- `Signer`: Includes only the signer's certificate.
227+
- `NotRoot`: Includes all of the certificates in the certificate chain, except for the root
228+
authority.
229+
- `All`: Includes all the certificates in the certificate chain.
222230

223231
```yaml
224232
Type: System.String
@@ -234,15 +242,15 @@ Accept wildcard characters: False
234242

235243
### -LiteralPath
236244

237-
Specifies the path to a file that is being signed. Unlike **FilePath**, the value of the
238-
**LiteralPath** parameter is used exactly as it is typed. No characters are interpreted as
245+
Specifies the path to a file that's being signed. Unlike **FilePath**, the value of the
246+
**LiteralPath** parameter is used exactly as it's typed. No characters are interpreted as
239247
wildcards. If the path includes escape characters, enclose it in single quotation marks. Single
240248
quotation marks tell PowerShell not to interpret any characters as escape sequences.
241249

242250
```yaml
243251
Type: System.String[]
244252
Parameter Sets: ByLiteralPath
245-
Aliases: PSPath
253+
Aliases: PSPath, LP
246254
247255
Required: True
248256
Position: Named
@@ -253,8 +261,8 @@ Accept wildcard characters: False
253261

254262
### -SourcePathOrExtension
255263

256-
This parameter appears in the syntax listing because it is defined in the base class that
257-
`Set-AuthenticodeSignature` is derived from. However, support for this parameter is not implemented
264+
This parameter appears in the syntax listing because it's defined in the base class that
265+
`Set-AuthenticodeSignature` is derived from. However, support for this parameter isn't implemented
258266
in `Set-AuthenticodeSignature`.
259267

260268
```yaml
@@ -272,12 +280,18 @@ Accept wildcard characters: False
272280
### -TimestampServer
273281

274282
Uses the specified time stamp server to add a time stamp to the signature. Type the URL of the time
275-
stamp server as a string. The URL must start with `https://` or `http://`.
283+
stamp server as a string. The URL must start with `http://`.
276284

277285
The time stamp represents the exact time that the certificate was added to the file. A time stamp
278286
prevents the script from failing if the certificate expires because users and programs can verify
279287
that the certificate was valid at the time of signing.
280288

289+
> [!NOTE]
290+
> PowerShell 7.3 added support for `https://` URLs with this parameter. However, the underlying API
291+
> doesn't support HTTPS. If you use HTTPS, the command returns an error, but the file is signed
292+
> without a time stamp. For more information, see
293+
> [Issue #25130](https://github.com/PowerShell/PowerShell/issues/25130).
294+
281295
```yaml
282296
Type: System.String
283297
Parameter Sets: (All)
@@ -308,7 +322,7 @@ Accept wildcard characters: False
308322

309323
### -WhatIf
310324

311-
Shows what would happen if the cmdlet runs. The cmdlet is not run.
325+
Shows what would happen if the cmdlet runs. The cmdlet isn't run.
312326

313327
```yaml
314328
Type: System.Management.Automation.SwitchParameter
@@ -347,6 +361,8 @@ This cmdlet is only available on Windows platforms.
347361

348362
## RELATED LINKS
349363

364+
[Authenticode](/windows-hardware/drivers/install/authenticode)
365+
350366
[Get-AuthenticodeSignature](Get-AuthenticodeSignature.md)
351367

352368
[Get-ExecutionPolicy](Get-ExecutionPolicy.md)

0 commit comments

Comments
 (0)