PowerShell: Unterschied zwischen den Versionen

Aus Meine Wiki
Zur Navigation springen Zur Suche springen
Zeile 23: Zeile 23:
  
 
   Invoke-RestMethod -Uri http://checkip.amazonaws.com/
 
   Invoke-RestMethod -Uri http://checkip.amazonaws.com/
 +
 +
 +
== Speed messen ==
 +
 +
Function Measure-NetworkSpeed{
 +
    # The test file has to be a 10MB file for the math to work. If you want to change sizes, modify the math to match
 +
    $TestFile  = 'https://ftp.sunet.se/mirror/parrotsec.org/parrot/misc/10MB.bin'
 +
    $TempFile  = Join-Path -Path $env:TEMP -ChildPath 'testfile.tmp'
 +
    $WebClient = New-Object Net.WebClient
 +
    $TimeTaken = Measure-Command { $WebClient.DownloadFile($TestFile,$TempFile) } | Select-Object -ExpandProperty TotalSeconds
 +
    $SpeedMbps = (10 / $TimeTaken) * 8
 +
    $Message = "{0:N2} Mbit/sec" -f ($SpeedMbps)
 +
    $Message
 +
}
 +
 +
Measure-NetworkSpeed

Version vom 16. März 2023, 12:20 Uhr

Signiert

PowerShell-Skriptausführung generell freigeben.

Um Skriptdateien der PowerShell ausführen zu können, müssen Sie deren Ausführung zulassen. Öffnen Sie das Eingabefenster der Windows PowerShell über den Kontextmenübefehl Als Administrator ausführen und tippen Sie dann den Befehl

Set-ExecutionPolicy Unrestricted

Version

Version auslesen.

 $PSVersionTable

Port

Test-NetConnection und die moderne Art TCP Ports zu testen (open/closed)

 Test-NetConnection kmsserver01 -port 1688

MY IP

Öffentliche IP Adresse mit Invoke-RestMethod in PowerShell ermitteln

 Invoke-RestMethod -Uri http://checkip.amazonaws.com/


Speed messen

Function Measure-NetworkSpeed{
   # The test file has to be a 10MB file for the math to work. If you want to change sizes, modify the math to match
   $TestFile  = 'https://ftp.sunet.se/mirror/parrotsec.org/parrot/misc/10MB.bin'
   $TempFile  = Join-Path -Path $env:TEMP -ChildPath 'testfile.tmp'
   $WebClient = New-Object Net.WebClient
   $TimeTaken = Measure-Command { $WebClient.DownloadFile($TestFile,$TempFile) } | Select-Object -ExpandProperty TotalSeconds
   $SpeedMbps = (10 / $TimeTaken) * 8
   $Message = "{0:N2} Mbit/sec" -f ($SpeedMbps)
   $Message
}
Measure-NetworkSpeed