Skip to content

Commit 1643434

Browse files
authored
Update get-VTFileReport.psm1
1 parent f72f7c9 commit 1643434

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

get-VTFileReport.psm1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Function get-VTFileReport
1010
param ([Parameter(Mandatory=$true)] [array]$h)
1111

1212
## Get your own VT API key here: https://www.virustotal.com/gui/join-us
13-
$VTApiKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
13+
$VTApiKey = "xxxxxxxxxxxxxx"
1414

1515
## Set TLS 1.2
1616
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@@ -30,6 +30,14 @@ Function get-VTFileReport
3030
$VTbody = @{resource = $hash; apikey = $VTApiKey}
3131
$VTresult = Invoke-RestMethod -Method GET -Uri 'https://www.virustotal.com/vtapi/v2/file/report' -Body $VTbody
3232

33+
## Calculate percentage if there is a result
34+
if ($VTresult.positives -ge 1) {
35+
$VTpct = (($VTresult.positives) / ($VTresult.total)) * 100
36+
$VTpct = [math]::Round($VTpct,2)
37+
}
38+
else {
39+
$VTpct = 0
40+
}
3341
## Custom Object for data output
3442
[PSCustomObject]@{
3543
resource = $VTresult.resource

0 commit comments

Comments
 (0)