Skip to content

Commit 4a977b9

Browse files
authored
Create AutoSign.ps1
1 parent d43df17 commit 4a977b9

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

AutoSign/v1.1.0/EN/AutoSign.ps1

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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 "`nYour 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)

0 commit comments

Comments
 (0)