-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-Speedtest.ps1
40 lines (26 loc) · 1.11 KB
/
Get-Speedtest.ps1
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
function Get-Speedtest {
speedtest | Tee-Object -variable clir
$list = ($clir.trim() -join "&").replace("&&","&").split("&") | select -skip 2
$Object = New-Object PSObject
foreach ($line in $list){
$name = [regex]::split($line.trim(),'^([^:]+):[ ]*')[1]
$value = [regex]::split($line,'^([^:]+):[ ]*')[2]
$value = $value.split("(")[0]
$Object | add-member Noteproperty $name $value
if($line -like "*(*)"){
$l = $line.split("(")[1] -replace("\)")
if($l -like "*=*"){
$name2 = $name + " " + $l.split("=").trim()[0]
$value2 = $l.split("=").trim()[1]
}elseif($l -like "*used:*"){
$name2 = $name + " " + $l.split(":").trim()[0]
$value2 = $l.split(":").trim()[1]
}elseif($l -like "*ms jitter"){
$name2 = "$name Jitter"
$value2 = $l.split("j").trim()[0]
}
$Object | add-member Noteproperty $name2 $value2
}
}
return $Object
}