-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSecurityMicrosoftWindows10.ps1
103 lines (92 loc) · 2.99 KB
/
SecurityMicrosoftWindows10.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
### Install the module
#Install-Module MSRCSecurityUpdates -Force
### Load the module
Import-Module -Name MsrcSecurityUpdates
# Month Format for MSRC
$Month = Get-Date -Format 'yyyy-MMM'
# Enter the Operating System you specifically want to focus on
$ClientOS_Type = "Windows 10 Version"
# Environment Variables
$Css = "<style>
body {
font-family: Arial, sans-serif;
font-size: 10px;
color: #FFFFFF;
background: #000000;
}
#title {
color: #FFFFFF;
font-size: 30px;
font-weight: bold;
height: 50px;
margin-left: 0px;
padding-top: 10px;
}
#subtitle {
font-size: 16px;
margin-left: 0px;
padding-bottom: 10px;
color: #FFFFFF;
}
table {
width: 100%;
border-collapse: collapse;
}
table td, table th {
border: 1px solid #FFFFFF;
padding: 3px 7px 2px 7px;
}
table th {
text-align: center;
padding-top: 5px;
padding-bottom: 4px;
background-color: #FFFFFF;
color: #000000;
}
table tr.alt td {
color: #000000;
background-color: #EAF2D3;
}
tr.critical {
color: white;
background-color: red;
}
</style>"
$Title = "<span style='font-weight:bold;font-size:24pt'>CVE List for Windows 10 " + $Month + "</span>"
$Logo = "<img src='C:\Users\Chicano\OneDrive\MCT\cloudnaquebradav2.png' alt='Logo' height='100' width='100'>"
$Header = "<div id='banner'>$Logo</div>`n" +
"<div id='title'>$Title</div>`n" +
"<div id='subtitle'>Report generated: $(Get-Date)</div>"
# Main Script Logic
$ID = Get-MsrcCvrfDocument -ID $Month
$ProductName = Get-MsrcCvrfAffectedSoftware -Vulnerability $ID.Vulnerability -ProductTree $ID.ProductTree | Where-Object { $_.Severity -in 'Critical', 'Important' -and ($_.FullProductName -match $ClientOS_Type) }
$Report = $ProductName | Select CVE, FullProductName, Severity, Impact, @{Name='KBArticle'; Expression={($_.KBArticle.ID | Select-Object -Unique) -join ', '}}, @{Name='BaseScore'; Expression={$_.CvssScoreSet.Base}}, @{Name='TemporalScore'; Expression={$_.CvssScoreSet.Temporal}}, @{Name='Vector'; Expression={$_.CvssScoreSet.Vector}} | ConvertTo-Html -As Table -Fragment | ForEach-Object {
if ($_ -match "<td.*?Critical.*?>") {
$_ -replace "<tr>", "<tr class='critical'>"
} else {
$_
}
}
# Combine CSS, Header, and Report into a full HTML document
$HtmlContent = @"
<html>
<head>
$Css
</head>
<body>
$Header
$Report
</body>
</html>
"@
# Save the HTML content to a file
$HtmlFilePath = "C:\Users\Chicano\OneDrive\vscode\PowerShell\arquivo2.html"
$HtmlContent | Out-File -FilePath $HtmlFilePath -Encoding utf8
# Send the HTML content via email
$SmtpServer = "smtp.seuservidor.com"
$From = "seuemail@dominio.com"
$To = "destinatario@dominio.com"
$Subject = "Relatório de Segurança Microsoft"
$Body = $HtmlContent
$Attachment = $HtmlFilePath
#Send-MailMessage -SmtpServer $SmtpServer -From $From -To $To -Subject $Subject -Body $Body -BodyAsHtml -Attachments $Attachment