Skip to content

Commit 8eccfe0

Browse files
committed
Added a try catch to first WMI call in the 'ByComputerName' parameter set. If the call fails the entire loop for that system will be terminated.
1 parent 58b3dee commit 8eccfe0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Functions/Test-WannaCryVulnerability.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<#PSScriptInfo
22
33
.Version
4-
1.2
4+
1.3
55
.Guid
66
477aa3f4-0434-4925-9c92-7323066cceb7
77
.Author
@@ -55,6 +55,8 @@
5555
SMB1ProtocolEnabled : True
5656
.Notes
5757
Not applicable to windows 10.
58+
.Link
59+
https://www.redsocks.eu/news/ransomware-wannacry/
5860
.Link
5961
https://dotps1.github.io
6062
.Link
@@ -158,7 +160,7 @@ process {
158160
continue
159161
}
160162

161-
if ($osCaption -match "Windows 10|2016") {
163+
if ($osCaption -match "Windows 10") {
162164
Write-Warning -Message "$osCaption is not vulnerable to WannaCry."
163165
continue
164166
}
@@ -212,7 +214,7 @@ process {
212214
$osCaption = Get-CimInstance -CimSession $cimSessionValue -ClassName Win32_OperatingSystem -Property Caption |
213215
Select-Object -ExpandProperty Caption
214216

215-
if ($osCaption -match "Windows 10|2016") {
217+
if ($osCaption -match "Windows 10") {
216218
Write-Error -Message "$osCaption is not vulnerable to WannaCry."
217219
continue
218220
}

0 commit comments

Comments
 (0)