You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Write-Host'No xml-file to assign service with port found! Use the parameter "-UpdateList" to download the latest version from IANA.org. This warning doesn`t affect the scanning procedure.'-ForegroundColor Yellow
167
+
Write-Warning-Message "No xml-file to assign service with port found! Use the parameter ""-UpdateList"" to download the latest version from IANA.org. This warning doesn`t affect the scanning procedure."
170
168
}
171
169
172
170
# Check if it is possible to assign service with port --> import xml-file
@@ -184,34 +182,37 @@ Process{
184
182
# Validate Port-Range
185
183
if($StartPort-gt$EndPort)
186
184
{
187
-
Write-Host"Invalid Port-Range... Check your input!"-ForegroundColor Red
188
-
return
185
+
Write-Error-Message "Invalid Port-Range... Check your input!"-Category InvalidArgument -ErrorAction Stop
189
186
}
190
187
191
188
# Check if host is reachable
192
-
Write-Verbose"Test if host is reachable..."
189
+
Write-Verbose-Message "Test if host is reachable..."
Write-Verbose"Scanning range from $StartPort to $EndPort ($PortsToScan Ports)"
214
-
Write-Verbose"Running with max $Threads threads"
214
+
Write-Verbose-Message "Scanning range from $StartPort to $EndPort ($PortsToScan Ports)"
215
+
Write-Verbose-Message "Running with max $Threads threads"
215
216
216
217
# Check if ComputerName is already an IPv4-Address, if not... try to resolve it
217
218
$IPv4Address= [String]::Empty
@@ -239,8 +240,7 @@ Process{
239
240
240
241
if([String]::IsNullOrEmpty($IPv4Address))
241
242
{
242
-
Write-Host"Could not get IPv4-Address for $ComputerName. (Try to enter an IPv4-Address instead of the Hostname)"-ForegroundColor Red
243
-
return
243
+
Write-Error-Message "Could not get IPv4-Address for $ComputerName. (Try to enter an IPv4-Address instead of the Hostname)"-Category InvalidData -ErrorAction Stop
244
244
}
245
245
}
246
246
@@ -268,23 +268,21 @@ Process{
268
268
$Status="Closed"
269
269
}
270
270
271
-
$Result=[pscustomobject] @{
271
+
[pscustomobject] @{
272
272
Port=$Port
273
273
Protocol="tcp"
274
274
Status=$Status
275
275
}
276
-
277
-
return$Result
278
276
}
279
277
280
-
Write-Verbose"Setting up RunspacePool..."
278
+
Write-Verbose-Message "Setting up RunspacePool..."
Write-Verbose"Waiting for jobs to complete & starting to process results..."
319
+
Write-Verbose-Message "Waiting for jobs to complete & starting to process results..."
322
320
323
321
# Total jobs to calculate percent complete, because jobs are removed after they are processed
324
322
$Jobs_Total=$Jobs.Count
@@ -331,7 +329,7 @@ Process{
331
329
# If no jobs finished yet, wait 500 ms and try again
332
330
if($Jobs_ToProcess-eq$null)
333
331
{
334
-
Write-Verbose"No jobs completed, wait 500ms..."
332
+
Write-Verbose-Message "No jobs completed, wait 500ms..."
335
333
336
334
Start-Sleep-Milliseconds 500
337
335
continue
@@ -350,7 +348,7 @@ Process{
350
348
351
349
Write-Progress-Activity "Waiting for jobs to complete... ($($Threads-$($RunspacePool.GetAvailableRunspaces())) of $Threads threads running)"-Id 1-PercentComplete $Progress_Percent-Status "$Jobs_Remaining remaining..."
0 commit comments