2026-03-04 17:59:33 -05:00
|
|
|
$DNSHelper = $Global:ToolsDirectory + '\ekdns.exe'
|
2026-03-04 22:49:05 -05:00
|
|
|
|
2026-03-04 23:00:20 -05:00
|
|
|
$DNSHelperRequiredVersion = '2.2.0'
|
2026-03-04 22:49:05 -05:00
|
|
|
$DownloadRequired = $false
|
|
|
|
|
|
|
|
|
|
If (Test-Path $DNSHelper) {
|
|
|
|
|
$versionOutput = (& $DNSHelper | Select-Object -First 1)
|
|
|
|
|
If ($versionOutput -match 'v(\d+\.\d+\.\d+)') {
|
|
|
|
|
If ($Matches[1] -ne $DNSHelperRequiredVersion) {
|
|
|
|
|
$DownloadRequired = $true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} Else {
|
|
|
|
|
$DownloadRequired = $true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Download the latest version of ekDNSHelper
|
|
|
|
|
If ($DownloadRequired) {
|
2026-03-04 17:59:33 -05:00
|
|
|
$DNSHelperURL = 'https://www.emberkom.com/tools/ekdns-x64.exe'
|
2026-03-04 18:11:28 -05:00
|
|
|
If (!(Test-Path ${Env:ProgramFiles(x86)})) {
|
2026-03-04 17:59:33 -05:00
|
|
|
$DNSHelperURL = 'https://www.emberkom.com/tools/ekdns-x86.exe'
|
|
|
|
|
}
|
2026-03-04 22:49:05 -05:00
|
|
|
If (Test-Path $DNSHelper) { Remove-Item -Path $DNSHelper -Force -ErrorAction SilentlyContinue }
|
|
|
|
|
Write-Output "Downloading latest version of ekDNSHelper"
|
2024-06-07 14:30:07 -04:00
|
|
|
Download-File -URL $DNSHelperURL -File $DNSHelper
|
|
|
|
|
}
|
2026-03-04 18:14:43 -05:00
|
|
|
|
|
|
|
|
# Delete the old version of ekDNSHelper if it exists
|
2026-03-04 22:55:16 -05:00
|
|
|
If ( Test-Path ($Global:ToolsDirectory + '\dns-helper.exe') ) {
|
2026-03-04 18:14:43 -05:00
|
|
|
Write-Output "Deleting old version of ekDNSHelper: ${Global:ToolsDirectory}\dns-helper.exe"
|
2026-03-04 22:55:16 -05:00
|
|
|
Remove-Item -Path ($Global:ToolsDirectory + '\dns-helper.exe') -Force -ErrorAction SilentlyContinue
|
2026-03-04 18:14:43 -05:00
|
|
|
}
|
|
|
|
|
|
2024-07-01 11:19:20 -04:00
|
|
|
$RefreshScript = $Global:ToolsDirectory + '\refresh-local-hosts.bat'
|
2024-07-01 11:24:24 -04:00
|
|
|
$todaysDate = Get-LongDate
|
2024-07-01 11:19:20 -04:00
|
|
|
$RefreshScriptHeader = @"
|
|
|
|
|
@echo off
|
|
|
|
|
REM Refresh IP to name mappings in local hosts file
|
|
|
|
|
REM This script was created by an automatic process and should not be edited manually
|
2024-07-01 11:26:12 -04:00
|
|
|
REM Author: David Yoder, Emberkom LLC (Fix-UpdateLocalHosts.ps1)
|
2024-07-01 11:24:24 -04:00
|
|
|
REM Updated: ${todaysDate}`n
|
2024-07-01 11:19:20 -04:00
|
|
|
"@
|
2024-06-07 14:30:07 -04:00
|
|
|
|
|
|
|
|
$Hosts = @(
|
|
|
|
|
'auth.services.mspbackups.com',
|
|
|
|
|
'ws.mspbackups.com'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
If ($BackupBucket.Length -ge 2 ) {
|
|
|
|
|
$Hosts += $BackupBucket
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$HostString = ''
|
|
|
|
|
ForEach ($Hostname in $Hosts) {
|
|
|
|
|
If ($HostString.Length -gt 0) { $HostString = $HostString + ',' + $Hostname }
|
|
|
|
|
Else { $HostString = $Hostname }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
If ( Test-Path $DNSHelper ) {
|
2026-03-04 17:59:33 -05:00
|
|
|
$commandString = """${DNSHelper}"" add -host ${HostString}"
|
2024-07-01 11:19:20 -04:00
|
|
|
$content = $RefreshScriptHeader + $commandString
|
|
|
|
|
Write-Output "Creating latest refresh script"
|
|
|
|
|
If ( Test-Path $RefreshScript ) { Remove-Item -Path $RefreshScript -Force }
|
|
|
|
|
Try {
|
|
|
|
|
New-Item -Path $RefreshScript -ItemType File -Force | Out-Null
|
|
|
|
|
Set-Content -Path $RefreshScript -Value $content
|
|
|
|
|
}
|
|
|
|
|
Catch { Write-Error $_.Exception.Message }
|
|
|
|
|
|
2024-06-07 14:30:07 -04:00
|
|
|
Write-Output "Updating local hosts file with name-to-IP mappings for the following host(s): ${HostString}"
|
2024-07-01 11:19:20 -04:00
|
|
|
& "${RefreshScript}"
|
2024-06-07 14:30:07 -04:00
|
|
|
} Else {
|
|
|
|
|
Write-Error "Cannot find the DNS Helper executable: ""${DNSHelper}"""
|
|
|
|
|
}
|