Add-CodeSignerSignature
SYNOPSIS
Adds a code-signing signature to a file.
SYNTAX
Add-CodeSignerSignature [-File] <Object> [[-HashAlgorithm] <String>] [[-CertificateSubject] <String>]
[[-TimeStampServer] <String>] [<CommonParameters>]
DESCRIPTION
The `Add-CodeSignerSignature` function signs a specified file using a code-signing certificate. It retrieves the certificate from the local certificate store based on the provided subject name and validates its validity period. The function supports specifying the hash algorithm and an optional timestamp server for the signature.
EXAMPLES
EXAMPLE 1
Signs the file `MyScript.ps1` using the default code-signing certificate and `SHA256` hash algorithm.
EXAMPLE 2
Signs the file `MyScript.ps1` using the default code-signing certificate and `SHA1` hash algorithm.
EXAMPLE 3
Add-CodeSignerSignature -File "C:\Scripts\MyScript.ps1" -CertificateSubject "*CN=CustomSigner*" -TimeStampServer "http://timestamp.example.com"
Signs the file `MyScript.ps1` using a custom code-signing certificate and a specified timestamp server.
PARAMETERS
-File
The file to be signed.
Type: Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-HashAlgorithm
The hash algorithm to use for signing. Defaults to `SHA256`.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: SHA256
Accept pipeline input: False
Accept wildcard characters: False
-CertificateSubject
The subject name of the code-signing certificate to use. Wildcards are supported. Defaults to `CN=District09 CodeSigner`.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: *CN=District09 CodeSigner*
Accept pipeline input: False
Accept wildcard characters: False
-TimeStampServer
The URL of the timestamp server to use for the signature. Defaults to `http://timestamp.globalsign.com/?signature=sha2`.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: Http://timestamp.globalsign.com/?signature=sha2
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.