Signing

We recommend signing your scripts and modules when publishing them to a gallery. You can view this as a seal of approval. Signing scripts not only enables you to use an AllSigned execution policy, it also protects you, as a developer, from trouble. If users change a script that you have signed with your personal code-signing certificate, you can easily prove that your script did not cause the 48th outage in production, but the small code change that the recipient of your script introduced:

# Signing your modules
$codeSigningCert = Get-ChildItem Cert:CurrentUsermy -CodeSigningCert
$param = @{
FilePath = @(
'.Ch10VoiceCommandsVoiceCommands.psd1'
'.Ch10VoiceCommandsVoiceCommands.psm1'
)
}
$setParam = $param.Clone()
$setParam.IncludeChain = 'all'
$setParam.Certificate = $codeSigningCert
Set-AuthenticodeSignature @setParam

# Check your signatures later on
Get-AuthenticodeSignature @param

The principles you have learned in Chapter 4, Advanced Coding Techniques, apply here as well. Once your module is complete and you are confident that the code you produced will run in production, it is time to sign the code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset