Signature Authenticode
Aller à la navigation
Aller à la recherche
Installation du rôle ADDS | Sécuriser son environnement Active Directory | Windows LAPS | gMSA
Archives : Contrôleur de domaine Windows Server 2003 | Intégration Client Ubuntu sur AD Windows Server 2003 | Windows Server 2008
Présentation
La signature Authenticode permet d'apposer une signature sur un fichier ou un script. Dans un contexte d'exécution de scripts PowerShell, on peut restreindre l'exécution uniquement à du code signé.
Signer un script
Signer un script PowerShell
- L'exemple suivant permet de signer le script PowerShell nommé MonScriptPowerShell.ps1 :
$cert = Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert Set-AuthenticodeSignature -FilePath MonScriptPowerShell.ps1 -Certificate $cert
Signer plusieurs scripts PowerShell
- L'exemple suivant permet de signer l'ensemble des scripts PowerShell contenu dans le répertoire C:\MES_SCRIPTS :
$PathScriptToSign = "C:\MES_SCRIPTS\"
$CertCodeSigning = Get-ChildItem Cert:\CurrentUser\My\ -CodeSigningCert
$ListScripts = Get-ChildItem -Path $PathScriptToSign -Name -Include *.ps1
foreach ($line in $ListScripts)
{
Set-AuthenticodeSignature "$PathScriptToSign$line" -Certificate $CertCodeSigning
}
Stratégie d'approbation d'exécution de code signé
Présentation
Par défaut, la stratégie Microsoft autorise l'exécution des scripts qu'ils soient signés ou pas.