-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPingMachine.ps1
More file actions
41 lines (40 loc) · 1.27 KB
/
Copy pathPingMachine.ps1
File metadata and controls
41 lines (40 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<#
.Note
Author : Rafael,kun,Vincent
Version : 1.0.1
Array problem fixed, Text file print properly.
#>
Clear
$IP = Read-Host -Prompt 'Ping'
$Attemp = Read-Host -Prompt 'Times of Attemp'
$Output_arr = @()
While ($Attemp -gt 0){
$time += 1
if((Test-Connection -computer $IP -Delay 1 -quiet)){
$Succeed += 1
$Output = "$time . $(Get-Date -format "dd-MM-yyyy HH:mm:ss"): $IP Successful Connected!"
Write-Host -ForegroundColor Green "$Output"
}Else {
$Failure += 0
$Output = "$time . $(Get-Date -format "dd-MM-yyyy HH:mm:ss"): $IP Unable to Connected!"
Write-Host -ForegroundColor Red "$Output"
}
$Output_arr += $Output
$Attemp -= 1
}
Write-Host "Testing Completed !"
Write-Host -ForegroundColor Green "Times of Succeed: $Succeed"
Write-Host -ForegroundColor Red "Times of Failure: $Failure "
$Output_arr
$Print = Read-Host -Prompt "Print Reult in Text File (Y/N) "
if($Print.ToUpper() -eq 'Y'){
$FileName = Read-Host -Prompt "Enter File Name "
$OutputFile = (Get-Location).Path + "\$FileName.txt"
try{
$IO = [System.IO.StreamWriter] $OutputFile
for ($i=0; $i -lt $Output_arr.Length;$i++){
$IO.WriteLine($Output_arr[$i])
}
$IO.close()
}finally{}
}