Skip to content

Commit d0ccd07

Browse files
committed
Code improved
1 parent eaff623 commit d0ccd07

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Scripts/IPv4PortScan.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ Process{
196196
$Info = "Would you like to continue? (perhaps only ICMP is blocked)"
197197

198198
$Options = [System.Management.Automation.Host.ChoiceDescription[]] @("&Yes", "&No")
199-
[int]$Defaultchoice = 0
200-
$Opt = $host.UI.PromptForChoice($Title , $Info, $Options, $Defaultchoice)
199+
[int]$DefaultChoice = 0
200+
$Opt = $host.UI.PromptForChoice($Title , $Info, $Options, $DefaultChoice)
201201

202202
switch($Opt)
203203
{
@@ -239,7 +239,7 @@ Process{
239239

240240
if([String]::IsNullOrEmpty($IPv4Address))
241241
{
242-
Write-Error -Message "Could not get IPv4-Address for $ComputerName. (Try to enter an IPv4-Address instead of the Hostname)" -Category InvalidData -ErrorAction Stop
242+
throw "Could not get IPv4-Address for $ComputerName. (Try to enter an IPv4-Address instead of the Hostname)"
243243
}
244244
}
245245

@@ -326,7 +326,7 @@ Process{
326326
# Process results, while waiting for other jobs
327327
Do {
328328
# Get all jobs, which are completed
329-
$Jobs_ToProcess = $Jobs | Where-Object {$_.Result.IsCompleted}
329+
$Jobs_ToProcess = $Jobs | Where-Object -FilterScript {$_.Result.IsCompleted}
330330

331331
# If no jobs finished yet, wait 500 ms and try again
332332
if($null -eq $Jobs_ToProcess)
@@ -338,7 +338,7 @@ Process{
338338
}
339339

340340
# Get jobs, which are not complete yet
341-
$Jobs_Remaining = ($Jobs | Where-Object {$_.Result.IsCompleted -eq $false}).Count
341+
$Jobs_Remaining = ($Jobs | Where-Object -FilterScript {$_.Result.IsCompleted -eq $false}).Count
342342

343343
# Catch when trying to divide through zero
344344
try {

0 commit comments

Comments
 (0)