added Multithread variant for PS 5.x

This commit is contained in:
2026-03-31 22:12:46 +02:00
commit 0a110a5512
2 changed files with 62 additions and 0 deletions

34
Parallel.ps1 Normal file
View File

@@ -0,0 +1,34 @@
$urls = @(
"www.google.de"
"www.amazon.de"
"www.github.com"
"www.youtube.com"
"www.gibtsnicht.com"
)
$start = Get-Date
$urls | ForEach-Object -Parallel {
$reachable = Test-Connection -ComputerName $_ -Quiet
if($reachable){
Write-Host "$($_) is reachable"
}else {
Write-Host "$($_) could not be reached"
}
}
<#
$urls | ForEach-Object {
$reachable = Test-Connection -ComputerName $_ -Quiet
if($reachable){
Write-Host "$($_) is reachable"
}else {
Write-Host "$($_) could not be reached"
}
}
#>
$end = Get-Date
$duration = $end - $start
Write-Host "Laufzeit: $($duration.TotalSeconds)"