Public/Functions/split/Wait-WebConnection.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 |
<#
.SYNOPSIS Waits for an internet connection to the specified Uri .DESCRIPTION Waits for an internet connection to the specified Uri .LINK https://osd.osdeploy.com/module/functions/webconnection #> function Wait-WebConnection { [CmdletBinding()] param ( [Parameter(ValueFromPipeline)] # Waits for a valid connection to a Uri [System.Uri] $Uri = 'powershellgallery.com' ) if ((Test-WebConnection -Uri "$Uri") -eq $true) { Write-Verbose "Wait-WebConnection to $Uri" } else { Write-Verbose "Wait-WebConnection to $Uri" do { Write-Verbose "Waiting 10 seconds to try again ..." Start-Sleep -Seconds 10 } until ((Test-WebConnection -Uri 'powershellgallery.com') -eq $true) } $Error.Clear() } |