Skip to content

Instantly share code, notes, and snippets.

@Santaro255
Created April 18, 2019 08:59
Show Gist options
  • Save Santaro255/72a3e94223fcb84c871d35b23f50a07d to your computer and use it in GitHub Desktop.
Save Santaro255/72a3e94223fcb84c871d35b23f50a07d to your computer and use it in GitHub Desktop.
<#
If you have UnknownError recreate script file with notepad.
This script must be signed first by
Set-AuthenticodeSignature -FilePath "PATH_TO_THIS_SCRIPT" -Certificate (Get-PfxCertificate "PATH_TO_CERT")
or just change ExecutionPolicy.
#>
function sign_cert($file) {
$certpath = "INSERT_PATH_TO_CERT"
$certpass = "INSERT_PASS_FOR_CERT"
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certpath, $certpass)
Set-AuthenticodeSignature -FilePath $file -Certificate $cert
}
$scriptfolder = Get-ChildItem "INSERT_FOLDER_WITH_SCRIPTS"
foreach ($item in $scriptfolder) {
sign_cert($item.FullName)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment