Skip to content

Commit

Permalink
Install-DbaMaintenanceSolution does not work inside a container (#9252)
Browse files Browse the repository at this point in the history
Co-authored-by: Chrissy LeMaire <[email protected]>
  • Loading branch information
david-garcia-garcia and potatoqualitee authored Mar 9, 2024
1 parent d23f1b3 commit ccaa682
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions public/Install-DbaMaintenanceSolution.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,18 @@ function Install-DbaMaintenanceSolution {
Write-ProgressHelper -ExcludePercent -Message "If Ola Hallengren's scripts are found, we will drop and recreate them"
}


# does this machine have internet access to download the files if required?
if (-not $isLinux -and -not $isMacOs) {
if ((Get-Command -Name Get-NetConnectionProfile -ErrorAction SilentlyContinue)) {
$script:internet = (Get-NetConnectionProfile).IPv4Connectivity -contains "Internet"
$script:internet = (Get-NetConnectionProfile -ErrorAction SilentlyContinue).IPv4Connectivity -contains "Internet"
} else {
try {
$network = [Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}")
$script:internet = ([Activator]::CreateInstance($network)).GetNetworkConnections() | ForEach-Object { $_.GetNetwork().GetConnectivity() } | Where-Object { ($_ -band 64) -eq 64 }
} catch {
# don't care
# probably a container with internet
$script:internet = $true
}
}

Expand Down

0 comments on commit ccaa682

Please sign in to comment.