File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 11
11
.ProjectUri
12
12
https://github.com/dotps1/PSFunctions
13
13
.ReleaseNotes
14
- Adding FullName for type Microsoft.Management.Infrastructure.CimSession, else Windows 8.1/WMF 5.0 cannot find the type .
14
+ 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 .
15
15
16
16
#>
17
17
@@ -87,7 +87,7 @@ param (
87
87
[Parameter (
88
88
ParameterSetName = " ByComputerName"
89
89
)]
90
- [PSCredential ]
90
+ [System.Management.Automation. PSCredential ]
91
91
$Credential = [PSCredential ]::Empty,
92
92
93
93
[Parameter (
@@ -151,15 +151,15 @@ process {
151
151
}
152
152
153
153
try {
154
- $osCaption = Get-WmiObject - ComputerName $nameValue - Class Win32_OperatingSystem - Property Caption - Credential $Credential |
154
+ $osCaption = Get-WmiObject - ComputerName $nameValue - Class Win32_OperatingSystem - Property Caption - Credential $Credential - ErrorAction Stop |
155
155
Select-Object - ExpandProperty Caption
156
156
} catch {
157
- Write-Error $_ .ToString ()
157
+ Write-Error - Message " Failed to contact WMI on ' $nameValue '. " - RecommendedAction " Verify WS-MAN is not being blocked by the firewall. "
158
158
continue
159
159
}
160
160
161
161
if ($osCaption -match " Windows 10|2016" ) {
162
- Write-Error - Message " $osCaption is not vulnerable to WannaCry."
162
+ Write-Warning - Message " $osCaption is not vulnerable to WannaCry."
163
163
continue
164
164
}
165
165
You can’t perform that action at this time.
0 commit comments