File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ $CertCodeSigning = Get-ChildItem Cert:\CurrentUser\TrustedPublisher\ - CodeSigningCert
2+ # Get the certificate able to sign scripts
3+ $TimestampServer = " http://timestamp.comodoca.com/authenticode"
4+ # Date and time of the signature
5+
6+ function fichier {
7+
8+ Clear-Host
9+
10+ $file = Read-Host " Enter the Name of your PowerShell script"
11+
12+ $FileToSign = " C:\Script\$file .ps1"
13+
14+ Set-AuthenticodeSignature $FileToSign - Certificate $CertCodeSigning - TimestampServer $TimestampServer
15+ # With the given variable, we sign the script
16+
17+ Write-Host " `n Your script is now signed `n "
18+
19+ pause
20+ exit
21+ }
22+
23+ function dossier {
24+
25+ Clear-Host
26+
27+ $DirToSign = " C:\Script\*.ps1"
28+
29+ Set-AuthenticodeSignature $DirToSign - Certificate $CertCodeSigning - TimestampServer $TimestampServer
30+ exit
31+ }
32+
33+ function menu {
34+
35+
36+ Write-Host " ##############################################"
37+
38+ Write-Host "
39+ _ _____ _
40+ /\ | | / ____(_)
41+ / \ _ _| |_ ___| (___ _ __ _ _ __
42+ / /\ \| | | | __/ _ \\___ \| |/ _` | '_ \
43+ / ____ \ |_| | || (_) |___) | | (_| | | | |
44+ /_/ \_\__,_|\__\___/_____/|_|\__, |_| |_|
45+ __/ |
46+ |___/
47+
48+
49+ "
50+
51+ Write-Host " ############################################## `n "
52+
53+
54+ Write-Host " This script allow you to AutoSign your PowerShell scripts `n "
55+
56+
57+ Write-Host " 1 : File `n "
58+ Write-Host " 2 : Directory `n "
59+ Write-Host " 3 : Exit `n "
60+ }
61+ menu
62+ do {
63+ $choix = Read-Host " Choose your option"
64+
65+ switch ($choix ){
66+ " 1" {
67+ fichier
68+ }
69+ " 2" {
70+ dossier
71+ }
72+ " 3" {
73+ exit
74+ }
75+ default {
76+ Write-Host " Incorrect value"
77+ }
78+ }
79+
80+ } while ($true )
You can’t perform that action at this time.
0 commit comments