Securing Powershell Scripts with Code-Signing Certificate

Ideally, all Powershell scripts should be signed by a code signing certificate by a certificate authority that is trusted by the host machine. You can also sign you Powershell script with a a self-signed code-signing certificate. You don't need any other tools like make cert to sign your Powershell script to generate self-signed code-signing certificate because Powershell has a built-in cmdlet ( New-SelfSignedCertificate ) to generate it. Create a Self-Signed Code-Signing Certificate with Powershell CmdLet $subject = "Imran Aftab Rana” $cert = New-SelfSignedCertificate -Subject $subject -Type CodeSigningCert -CertStoreLocation cert:\LocalMachine\My The above cmdlet creates a self-signed code-signing certificate and places it in Local Machine Personal certificate store. Export a Code-Signing Certificate with Powershell CmdLet You can also export the certificate into a .p7b file and import it into another system or within same machine. Export-Certifica...