« Signature Authenticode » : différence entre les versions

De NCad Wiki
Aller à la navigation Aller à la recherche
(Page créée avec « = 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-... »)
 
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
{{Rôles_Active_Directory}}
= Présentation =
= Présentation =



Version du 1 septembre 2025 à 15:44

Rôles Active Directory

Installation du rôle ADCS | Gestion des certificats | Authentification par cartes à puce

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
}