Browse Source

`DNSoverHTTPS` function re-written

pull/703/head
Dmitry Nefedov 2 months ago
parent
commit
8c45e49d68
  1. 64
      Wrapper/Config/config_Windows_10.json
  2. 64
      Wrapper/Config/config_Windows_10_LTSC.json
  3. 54
      Wrapper/Config/config_Windows_11.json
  4. 54
      Wrapper/Config/config_Windows_11_ARM.json
  5. 55
      Wrapper/Config/config_Windows_11_LTSC.json
  6. 14
      Wrapper/Localizations/de-DE/tooltip_Windows_10.json
  7. 20
      Wrapper/Localizations/de-DE/tooltip_Windows_11.json
  8. 20
      Wrapper/Localizations/de-DE/tooltip_Windows_11_ARM.json
  9. 14
      Wrapper/Localizations/en-US/tooltip_Windows_10.json
  10. 20
      Wrapper/Localizations/en-US/tooltip_Windows_11.json
  11. 20
      Wrapper/Localizations/en-US/tooltip_Windows_11_ARM.json
  12. 14
      Wrapper/Localizations/ru-RU/tooltip_Windows_10.json
  13. 20
      Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
  14. 20
      Wrapper/Localizations/ru-RU/tooltip_Windows_11_ARM.json
  15. 2
      src/Sophia_Script_for_Windows_10/Module/Private/PostActions.ps1
  16. 2
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Private/PostActions.ps1
  17. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Private/PostActions.ps1
  18. 2
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Private/PostActions.ps1
  19. 24
      src/Sophia_Script_for_Windows_11/Import-TabCompletion.ps1
  20. 2
      src/Sophia_Script_for_Windows_11/Module/Private/PostActions.ps1
  21. 253
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  22. 30
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  23. 24
      src/Sophia_Script_for_Windows_11_ARM/Import-TabCompletion.ps1
  24. 2
      src/Sophia_Script_for_Windows_11_ARM/Module/Private/PostActions.ps1
  25. 251
      src/Sophia_Script_for_Windows_11_ARM/Module/Sophia.psm1
  26. 25
      src/Sophia_Script_for_Windows_11_ARM/Sophia.ps1
  27. 24
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Import-TabCompletion.ps1
  28. 2
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/PostActions.ps1
  29. 251
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Sophia.psm1
  30. 30
      src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Sophia.ps1
  31. 24
      src/Sophia_Script_for_Windows_11_LTSC_2024/Import-TabCompletion.ps1
  32. 2
      src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Private/PostActions.ps1
  33. 251
      src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1
  34. 30
      src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1
  35. 24
      src/Sophia_Script_for_Windows_11_PowerShell_7/Import-TabCompletion.ps1
  36. 2
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Private/PostActions.ps1
  37. 251
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  38. 30
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

64
Wrapper/Config/config_Windows_10.json

@ -2110,70 +2110,6 @@
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Region": "Microsoft Defender & Security",
"Control": "cmbcmbcmb",
"Required": "false",
"Function": "DNSoverHTTPS",
"Key": "SYSTEM\\CurrentControlSet\\Services\\Dnscache\\Parameters\\DohWellKnownServers",
"PrefixArg2": "PrimaryDNS",
"PrefixArg3": "SecondaryDNS",
"Arg2_3_Width": "145",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Arg2": {
"Zero": {
"Tag": "1.0.0.1"
},
"One": {
"Tag": "1.1.1.1"
},
"Two": {
"Tag": "149.112.112.112"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
}
},
"Arg3": {
"Zero": {
"Tag": "1.0.0.1"
},
"One": {
"Tag": "1.1.1.1"
},
"Two": {
"Tag": "149.112.112.112"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
}
},
"Preset": "Zero",
"WindowsDefault": "One",
"Preset2": "Zero",
"WindowsDefault2": "",
"Preset3": "One",
"WindowsDefault3": ""
},
{
"Region": "Context menu",
"Control": "cmb",

64
Wrapper/Config/config_Windows_10_LTSC.json

@ -2086,70 +2086,6 @@
"LTSC2019": "true",
"LTSC2021": "true"
},
{
"Region": "Microsoft Defender & Security",
"Control": "cmbcmbcmb",
"Required": "false",
"Function": "DNSoverHTTPS",
"Key": "SYSTEM\\CurrentControlSet\\Services\\Dnscache\\Parameters\\DohWellKnownServers",
"PrefixArg2": "PrimaryDNS",
"PrefixArg3": "SecondaryDNS",
"Arg2_3_Width": "145",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Arg2": {
"Zero": {
"Tag": "1.0.0.1"
},
"One": {
"Tag": "1.1.1.1"
},
"Two": {
"Tag": "149.112.112.112"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
}
},
"Arg3": {
"Zero": {
"Tag": "1.0.0.1"
},
"One": {
"Tag": "1.1.1.1"
},
"Two": {
"Tag": "149.112.112.112"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
}
},
"Preset": "Zero",
"WindowsDefault": "One",
"Preset2": "Zero",
"WindowsDefault2": "",
"Preset3": "One",
"WindowsDefault3": ""
},
{
"Region": "Context menu",
"Control": "cmb",

54
Wrapper/Config/config_Windows_11.json

@ -1951,67 +1951,25 @@
},
{
"Region": "Microsoft Defender & Security",
"Control": "cmbcmbcmb",
"Control": "cmb",
"Required": "false",
"Function": "DNSoverHTTPS",
"Key": "SYSTEM\\CurrentControlSet\\Services\\Dnscache\\Parameters\\DohWellKnownServers",
"PrefixArg2": "PrimaryDNS",
"PrefixArg3": "SecondaryDNS",
"Arg2_3_Width": "145",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Arg2": {
"Zero": {
"Tag": "1.0.0.1"
},
"One": {
"Tag": "1.1.1.1"
},
"Two": {
"Tag": "149.112.112.112"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
}
},
"Arg3": {
"Zero": {
"Tag": "1.0.0.1"
"Tag": "Cloudflare"
},
"One": {
"Tag": "1.1.1.1"
"Tag": "Google"
},
"Two": {
"Tag": "149.112.112.112"
"Tag": "Quad9"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
"Tag": "ComssOne"
}
},
"Preset": "Zero",
"WindowsDefault": "One",
"Preset2": "Zero",
"WindowsDefault2": "",
"Preset3": "One",
"WindowsDefault3": ""
"WindowsDefault": "One"
},
{
"Region": "Microsoft Defender & Security",

54
Wrapper/Config/config_Windows_11_ARM.json

@ -1935,67 +1935,25 @@
},
{
"Region": "Microsoft Defender & Security",
"Control": "cmbcmbcmb",
"Control": "cmb",
"Required": "false",
"Function": "DNSoverHTTPS",
"Key": "SYSTEM\\CurrentControlSet\\Services\\Dnscache\\Parameters\\DohWellKnownServers",
"PrefixArg2": "PrimaryDNS",
"PrefixArg3": "SecondaryDNS",
"Arg2_3_Width": "145",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Arg2": {
"Zero": {
"Tag": "1.0.0.1"
},
"One": {
"Tag": "1.1.1.1"
},
"Two": {
"Tag": "149.112.112.112"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
}
},
"Arg3": {
"Zero": {
"Tag": "1.0.0.1"
"Tag": "Cloudflare"
},
"One": {
"Tag": "1.1.1.1"
"Tag": "Google"
},
"Two": {
"Tag": "149.112.112.112"
"Tag": "Quad9"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
"Tag": "ComssOne"
}
},
"Preset": "Zero",
"WindowsDefault": "One",
"Preset2": "Zero",
"WindowsDefault2": "",
"Preset3": "One",
"WindowsDefault3": ""
"WindowsDefault": "One"
},
{
"Region": "Microsoft Defender & Security",

55
Wrapper/Config/config_Windows_11_LTSC.json

@ -1945,68 +1945,25 @@
},
{
"Region": "Microsoft Defender & Security",
"Control": "cmbcmbcmb",
"Control": "cmb",
"Required": "false",
"Function": "DNSoverHTTPS",
"Key": "SYSTEM\\CurrentControlSet\\Services\\Dnscache\\Parameters\\DohWellKnownServers",
"PrefixArg2": "PrimaryDNS",
"PrefixArg3": "SecondaryDNS",
"Arg2_3_Width": "145",
"Arg": {
"Zero": {
"Tag": "Enable"
},
"One": {
"Tag": "Disable"
}
},
"Arg2": {
"Zero": {
"Tag": "1.0.0.1"
},
"One": {
"Tag": "1.1.1.1"
},
"Two": {
"Tag": "149.112.112.112"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
}
},
"Arg3": {
"Zero": {
"Tag": "1.0.0.1"
"Tag": "Cloudflare"
},
"One": {
"Tag": "1.1.1.1"
"Tag": "Google"
},
"Two": {
"Tag": "149.112.112.112"
"Tag": "Quad9"
},
"Three": {
"Tag": "8.8.4.4"
},
"Four": {
"Tag": "8.8.8.8"
},
"Five": {
"Tag": "9.9.9.9"
"Tag": "ComssOne"
}
},
"Preset": "Zero",
"WindowsDefault": "One",
"Preset2": "Zero",
"WindowsDefault2": "",
"Preset3": "One",
"WindowsDefault3": "",
"LTSC2024": "true"
"WindowsDefault": "One"
},
{
"Region": "Microsoft Defender & Security",

14
Wrapper/Localizations/de-DE/tooltip_Windows_10.json

@ -1752,20 +1752,6 @@
}
}
},
{
"Region": "Microsoft Defender & Security",
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Aktiviert DNS-over-HTTPS für IPv4. Gültige IPv4-Adressen: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.91."
},
"One": {
"Tag": "Disable",
"ToolTip": "Deaktiviert DNS-over-HTTPS für IPv4 (Standardwert)."
}
}
},
{
"Region": "Context menu",
"Function": "MSIExtractContext",

20
Wrapper/Localizations/de-DE/tooltip_Windows_11.json

@ -1692,16 +1692,24 @@
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Aktiviert DNS-over-HTTPS für IPv4. Gültige IPv4-Adressen: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.91."
"Tag": "Cloudflare",
"ToolTip": "Aktivieren Sie DNS-over-HTTPS mit Cloudflare DNS."
},
"One": {
"Tag": "Disable",
"ToolTip": "Deaktiviert DNS-over-HTTPS für IPv4 (Standardwert)."
"Tag": "Google",
"ToolTip": "Aktivieren Sie DNS-over-HTTPS mit Google DNS."
},
"Two": {
"Tag": "ComssOneDNS",
"ToolTip": "DNS-over-HTTPS über den Comss.one-DNS-Server aktivieren."
"Tag": "Quad9",
"ToolTip": "Aktivieren Sie DNS-over-HTTPS mit Quad9 DNS."
},
"Three": {
"Tag": "ComssOne",
"ToolTip": "Aktivieren Sie DNS-over-HTTPS mit ComssOne DNS."
},
"Four": {
"Tag": "Disable",
"ToolTip": "Standard-DNS-Einträge des Internetdienstanbieters festlegen (Standardwert)."
}
}
},

20
Wrapper/Localizations/de-DE/tooltip_Windows_11_ARM.json

@ -1673,16 +1673,24 @@
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Aktiviert DNS-over-HTTPS für IPv4. Gültige IPv4-Adressen: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.91."
"Tag": "Cloudflare",
"ToolTip": "Aktivieren Sie DNS-over-HTTPS mit Cloudflare DNS."
},
"One": {
"Tag": "Disable",
"ToolTip": "Deaktiviert DNS-over-HTTPS für IPv4 (Standardwert)."
"Tag": "Google",
"ToolTip": "Aktivieren Sie DNS-over-HTTPS mit Google DNS."
},
"Two": {
"Tag": "ComssOneDNS",
"ToolTip": "DNS-over-HTTPS über den Comss.one-DNS-Server aktivieren."
"Tag": "Quad9",
"ToolTip": "Aktivieren Sie DNS-over-HTTPS mit Quad9 DNS."
},
"Three": {
"Tag": "ComssOne",
"ToolTip": "Aktivieren Sie DNS-over-HTTPS mit ComssOne DNS."
},
"Four": {
"Tag": "Disable",
"ToolTip": "Standard-DNS-Einträge des Internetdienstanbieters festlegen (Standardwert)."
}
}
},

14
Wrapper/Localizations/en-US/tooltip_Windows_10.json

@ -1753,20 +1753,6 @@
}
}
},
{
"Region": "Microsoft Defender & Security",
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Enable DNS-over-HTTPS for IPv4. The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9."
},
"One": {
"Tag": "Disable",
"ToolTip": "Disable DNS-over-HTTPS for IPv4 (default value)."
}
}
},
{
"Region": "Context menu",
"Function": "MSIExtractContext",

20
Wrapper/Localizations/en-US/tooltip_Windows_11.json

@ -1692,16 +1692,24 @@
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Enable DNS-over-HTTPS for IPv4. The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9."
"Tag": "Cloudflare",
"ToolTip": "Enable DNS-over-HTTPS using Cloudflare DNS."
},
"One": {
"Tag": "Disable",
"ToolTip": "Disable DNS-over-HTTPS for IPv4 (default value)."
"Tag": "Google",
"ToolTip": "Enable DNS-over-HTTPS using Google Public DNS."
},
"Two": {
"Tag": "ComssOneDNS",
"ToolTip": "Enable DNS-over-HTTPS via Comss.one DNS server."
"Tag": "Quad9",
"ToolTip": "Enable DNS-over-HTTPS using Quad9 DNS."
},
"Three": {
"Tag": "ComssOne",
"ToolTip": "Enable DNS-over-HTTPS using Comss.one DNS."
},
"Four": {
"Tag": "Disable",
"ToolTip": "Set default ISP's DNS records (default value)."
}
}
},

20
Wrapper/Localizations/en-US/tooltip_Windows_11_ARM.json

@ -1673,16 +1673,24 @@
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Enable DNS-over-HTTPS for IPv4. The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9."
"Tag": "Cloudflare",
"ToolTip": "Enable DNS-over-HTTPS using Cloudflare DNS."
},
"One": {
"Tag": "Disable",
"ToolTip": "Disable DNS-over-HTTPS for IPv4 (default value)."
"Tag": "Google",
"ToolTip": "Enable DNS-over-HTTPS using Google Public DNS."
},
"Two": {
"Tag": "ComssOneDNS",
"ToolTip": "Enable DNS-over-HTTPS via Comss.one DNS server."
"Tag": "Quad9",
"ToolTip": "Enable DNS-over-HTTPS using Quad9 DNS."
},
"Three": {
"Tag": "ComssOne",
"ToolTip": "Enable DNS-over-HTTPS using Comss.one DNS."
},
"Four": {
"Tag": "Disable",
"ToolTip": "Set default ISP's DNS records (default value)."
}
}
},

14
Wrapper/Localizations/ru-RU/tooltip_Windows_10.json

@ -1752,20 +1752,6 @@
}
}
},
{
"Region": "Microsoft Defender & Security",
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Включить DNS-over-HTTPS для IPv4. Действительные IPv4-адреса: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9."
},
"One": {
"Tag": "Disable",
"ToolTip": "Выключить DNS-over-HTTPS для IPv4 (значение по умолчанию)."
}
}
},
{
"Region": "Context menu",
"Function": "MSIExtractContext",

20
Wrapper/Localizations/ru-RU/tooltip_Windows_11.json

@ -1692,16 +1692,24 @@
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Включить DNS-over-HTTPS для IPv4. Действительные IPv4-адреса: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9."
"Tag": "Cloudflare",
"ToolTip": "Установить Cloudflare DNS, используя DNS-over-HTTPS."
},
"One": {
"Tag": "Disable",
"ToolTip": "Выключить DNS-over-HTTPS для IPv4 (значение по умолчанию)."
"Tag": "Google",
"ToolTip": "Установить Google Public DNS, используя DNS-over-HTTPS."
},
"Two": {
"Tag": "ComssOneDNS",
"ToolTip": "Включить DNS-over-HTTPS через DNS-сервер Comss.one."
"Tag": "Quad9",
"ToolTip": "Установить Google DNS, используя DNS-over-HTTPS."
},
"Three": {
"Tag": "ComssOne",
"ToolTip": "Установить Google DNS, используя DNS-over-HTTPS."
},
"Four": {
"Tag": "Disable",
"ToolTip": "становить DNS-записи вашего провайдера (значение по умолчанию)."
}
}
},

20
Wrapper/Localizations/ru-RU/tooltip_Windows_11_ARM.json

@ -1673,16 +1673,24 @@
"Function": "DNSoverHTTPS",
"Arg": {
"Zero": {
"Tag": "Enable",
"ToolTip": "Включить DNS-over-HTTPS для IPv4. Действительные IPv4-адреса: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9."
"Tag": "Cloudflare",
"ToolTip": "Установить Cloudflare DNS, используя DNS-over-HTTPS."
},
"One": {
"Tag": "Disable",
"ToolTip": "Выключить DNS-over-HTTPS для IPv4 (значение по умолчанию)."
"Tag": "Google",
"ToolTip": "Установить Google Public DNS, используя DNS-over-HTTPS."
},
"Two": {
"Tag": "ComssOneDNS",
"ToolTip": "Включить DNS-over-HTTPS через DNS-сервер Comss.one."
"Tag": "Quad9",
"ToolTip": "Установить Google DNS, используя DNS-over-HTTPS."
},
"Three": {
"Tag": "ComssOne",
"ToolTip": "Установить Google DNS, используя DNS-over-HTTPS."
},
"Four": {
"Tag": "Disable",
"ToolTip": "становить DNS-записи вашего провайдера (значение по умолчанию)."
}
}
},

2
src/Sophia_Script_for_Windows_10/Module/Private/PostActions.ps1

@ -124,8 +124,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

2
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Private/PostActions.ps1

@ -114,8 +114,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

2
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Private/PostActions.ps1

@ -124,8 +124,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

2
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Private/PostActions.ps1

@ -124,8 +124,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

24
src/Sophia_Script_for_Windows_11/Import-TabCompletion.ps1

@ -190,30 +190,6 @@ $Parameters = @{
}
}
# If a module command is DNSoverHTTPS
if ($Command -eq "DNSoverHTTPS")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get the valid IPv4 addresses array
# ((Get-Command -Name DNSoverHTTPS).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Select-Object -Unique
$ValidValues = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValue in $ValidValues)
{
$ValidValuesDescending = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValueDescending in $ValidValuesDescending)
{
# The "DNSoverHTTPS -Enable -PrimaryDNS x.x.x.x -SecondaryDNS x.x.x.x" construction
"DNSoverHTTPS -Enable -PrimaryDNS $ValidValue -SecondaryDNS $ValidValueDescending" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
}
"DNSoverHTTPS -Disable" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
"DNSoverHTTPS -ComssOneDNS" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
continue
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

2
src/Sophia_Script_for_Windows_11/Module/Private/PostActions.ps1

@ -114,8 +114,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

253
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -7599,7 +7599,7 @@ function Install-VCRedist
.NOTES
Machine-wide
#>
function Install-DotNetRuntimes
function Install-DotNetRuntimes
{
[CmdletBinding()]
param
@ -10834,31 +10834,40 @@ function WindowsSandbox
<#
.SYNOPSIS
DNS-over-HTTPS for IPv4
Configure DNS using DNS-over-HTTPS
.PARAMETER Enable
Enable DNS-over-HTTPS for IPv4
.PARAMETER Cloudflare
Enable DNS-over-HTTPS using Cloudflare DNS
.PARAMETER Google
Enable DNS-over-HTTPS using Google Public DNS
.PARAMETER Quad9
Enable DNS-over-HTTPS using Quad9 DNS
.PARAMETER ComssOne
Enable DNS-over-HTTPS using Comss.one DNS
.PARAMETER Disable
Disable DNS-over-HTTPS for IPv4
Set default ISP's DNS records
.EXAMPLE
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
DNSoverHTTPS -Cloudflare
.EXAMPLE Enable DNS-over-HTTPS via Comss.one DNS server
DNSoverHTTPS -ComssOneDNS
.EXAMPLE
DNSoverHTTPS -Google
.EXAMPLE
DNSoverHTTPS -Disable
DNSoverHTTPS -Quad9
.NOTES
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
.EXAMPLE
DNSoverHTTPS -ComssOne
.LINK
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.EXAMPLE
DNSoverHTTPS -Disable
.LINK
https://www.comss.ru/page.php?id=7315
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.NOTES
Machine-wide
@ -10870,38 +10879,31 @@ function DNSoverHTTPS
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
ParameterSetName = "Cloudflare"
)]
[switch]
$Enable,
$Cloudflare,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $SecondaryDNS)
})]
[string]
$PrimaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Google"
)]
[switch]
$Google,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $PrimaryDNS)
})]
[string]
$SecondaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Quad9"
)]
[switch]
$Quad9,
# https://www.comss.ru/page.php?id=7315
[Parameter(
Mandatory = $true,
ParameterSetName = "ComssOneDNS"
ParameterSetName = "ComssOne"
)]
[switch]
$ComssOneDNS,
$ComssOne,
[Parameter(
Mandatory = $true,
@ -10922,125 +10924,88 @@ function DNSoverHTTPS
$InterfaceGuids = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).InterfaceGuid)
}
switch ($PSCmdlet.ParameterSetName)
if ($Disable)
{
"Enable"
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Set a primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
# Encrypted preffered, unencrypted allowed
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
"ComssOneDNS"
else
{
# Resolve dns.comss.one to get its IP address to use
try
{
$ResolveComss = Resolve-DnsName -Name dns.comss.one -NoHostsFile -Verbose
}
catch [System.Net.WebException]
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -Verbose
Write-Error -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -ErrorAction SilentlyContinue
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
return
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Some ISPs block IP address resolving, and user get only one IP address
if ($ResolveComss.IPAddress.Count -eq 1)
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
}
else
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
$SecondIPAddress = $ResolveComss.IPAddress | Select-Object -Last 1
}
return
}
# Set a primary and secondary DNS servers
# https://www.comss.ru/page.php?id=7315
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
if ($SecondIPAddress)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
else
{
if ($SecondIPAddress)
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
switch ($PSCmdlet.ParameterSetName)
{
# https://developers.cloudflare.com/1.1.1.1/setup/windows/
"Cloudflare"
{
$PrimaryDNS = "1.1.1.1"
$SecondaryDNS = "1.0.0.1"
}
# https://developers.google.com/speed/public-dns/docs/using
"Google"
{
$PrimaryDNS = "8.8.8.8"
$SecondaryDNS = "8.8.4.4"
}
# https://quad9.net/service/service-addresses-and-features/
"Quad9"
{
$PrimaryDNS = "9.9.9.9"
$SecondaryDNS = "149.112.112.112"
}
# https://www.comss.ru/page.php?id=7315
"ComssOne"
{
$PrimaryDNS = "83.220.169.155"
$SecondaryDNS = "212.109.195.93"
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
# Set primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
if ($SecondIPAddress)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
"Disable"
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
else
{
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Encrypted preffered, unencrypted allowed
if ($ComssOne)
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
else
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
}

30
src/Sophia_Script_for_Windows_11/Sophia.ps1

@ -1124,23 +1124,25 @@ SaveZoneInformation -Disable
# Выключить Windows Sandbox (значение по умолчанию). Применимо только к редакциям Professional, Enterprise и Education
# WindowsSandbox -Disable
<#
Enable DNS-over-HTTPS for IPv4
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
# Enable DNS-over-HTTPS using Cloudflare DNS
# Установить Cloudflare DNS, используя DNS-over-HTTPS
DNSoverHTTPS -Cloudflare
Включить DNS-over-HTTPS для IPv4
Действительные IPv4-адреса: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
#>
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
# Enable DNS-over-HTTPS using Google Public DNS
# Установить Google Public DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Google
# Disable DNS-over-HTTPS for IPv4 (default value)
# Выключить DNS-over-HTTPS для IPv4 (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable DNS-over-HTTPS using Quad9
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Quad9
# Enable DNS-over-HTTPS via Comss.one DNS server
# Включить DNS-over-HTTPS через DNS-сервер Comss.one
# https://www.comss.ru/page.php?id=7315
# DNSoverHTTPS -ComssOneDNS
# Enable DNS-over-HTTPS using Comss.one
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -ComssOne
# Set default ISP's DNS records (default value)
# Установить DNS-записи вашего провайдера (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable Local Security Authority protection to prevent code injection
# Включить защиту локальной системы безопасности, чтобы предотвратить внедрение кода

24
src/Sophia_Script_for_Windows_11_ARM/Import-TabCompletion.ps1

@ -166,30 +166,6 @@ $Parameters = @{
}
}
# If a module command is DNSoverHTTPS
if ($Command -eq "DNSoverHTTPS")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get the valid IPv4 addresses array
# ((Get-Command -Name DNSoverHTTPS).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Select-Object -Unique
$ValidValues = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValue in $ValidValues)
{
$ValidValuesDescending = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValueDescending in $ValidValuesDescending)
{
# The "DNSoverHTTPS -Enable -PrimaryDNS x.x.x.x -SecondaryDNS x.x.x.x" construction
"DNSoverHTTPS -Enable -PrimaryDNS $ValidValue -SecondaryDNS $ValidValueDescending" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
}
"DNSoverHTTPS -Disable" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
"DNSoverHTTPS -ComssOneDNS" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
continue
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

2
src/Sophia_Script_for_Windows_11_ARM/Module/Private/PostActions.ps1

@ -114,8 +114,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

251
src/Sophia_Script_for_Windows_11_ARM/Module/Sophia.psm1

@ -10721,31 +10721,40 @@ function WindowsSandbox
<#
.SYNOPSIS
DNS-over-HTTPS for IPv4
Configure DNS using DNS-over-HTTPS
.PARAMETER Enable
Enable DNS-over-HTTPS for IPv4
.PARAMETER Cloudflare
Enable DNS-over-HTTPS using Cloudflare DNS
.PARAMETER Google
Enable DNS-over-HTTPS using Google Public DNS
.PARAMETER Quad9
Enable DNS-over-HTTPS using Quad9 DNS
.PARAMETER ComssOne
Enable DNS-over-HTTPS using Comss.one DNS
.PARAMETER Disable
Disable DNS-over-HTTPS for IPv4
Set default ISP's DNS records
.EXAMPLE
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
DNSoverHTTPS -Cloudflare
.EXAMPLE Enable DNS-over-HTTPS via Comss.one DNS server
DNSoverHTTPS -ComssOneDNS
.EXAMPLE
DNSoverHTTPS -Google
.EXAMPLE
DNSoverHTTPS -Disable
DNSoverHTTPS -Quad9
.NOTES
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
.EXAMPLE
DNSoverHTTPS -ComssOne
.LINK
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.EXAMPLE
DNSoverHTTPS -Disable
.LINK
https://www.comss.ru/page.php?id=7315
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.NOTES
Machine-wide
@ -10757,38 +10766,31 @@ function DNSoverHTTPS
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
ParameterSetName = "Cloudflare"
)]
[switch]
$Enable,
$Cloudflare,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $SecondaryDNS)
})]
[string]
$PrimaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Google"
)]
[switch]
$Google,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $PrimaryDNS)
})]
[string]
$SecondaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Quad9"
)]
[switch]
$Quad9,
# https://www.comss.ru/page.php?id=7315
[Parameter(
Mandatory = $true,
ParameterSetName = "ComssOneDNS"
ParameterSetName = "ComssOne"
)]
[switch]
$ComssOneDNS,
$ComssOne,
[Parameter(
Mandatory = $true,
@ -10809,125 +10811,88 @@ function DNSoverHTTPS
$InterfaceGuids = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).InterfaceGuid)
}
switch ($PSCmdlet.ParameterSetName)
if ($Disable)
{
"Enable"
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Set a primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
# Encrypted preffered, unencrypted allowed
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
"ComssOneDNS"
else
{
# Resolve dns.comss.one to get its IP address to use
try
{
$ResolveComss = Resolve-DnsName -Name dns.comss.one -NoHostsFile -Verbose
}
catch [System.Net.WebException]
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -Verbose
Write-Error -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -ErrorAction SilentlyContinue
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
return
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Some ISPs block IP address resolving, and user get only one IP address
if ($ResolveComss.IPAddress.Count -eq 1)
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
}
else
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
$SecondIPAddress = $ResolveComss.IPAddress | Select-Object -Last 1
}
return
}
# Set a primary and secondary DNS servers
# https://www.comss.ru/page.php?id=7315
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
if ($SecondIPAddress)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
else
{
if ($SecondIPAddress)
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
switch ($PSCmdlet.ParameterSetName)
{
# https://developers.cloudflare.com/1.1.1.1/setup/windows/
"Cloudflare"
{
$PrimaryDNS = "1.1.1.1"
$SecondaryDNS = "1.0.0.1"
}
# https://developers.google.com/speed/public-dns/docs/using
"Google"
{
$PrimaryDNS = "8.8.8.8"
$SecondaryDNS = "8.8.4.4"
}
# https://quad9.net/service/service-addresses-and-features/
"Quad9"
{
$PrimaryDNS = "9.9.9.9"
$SecondaryDNS = "149.112.112.112"
}
# https://www.comss.ru/page.php?id=7315
"ComssOne"
{
$PrimaryDNS = "83.220.169.155"
$SecondaryDNS = "212.109.195.93"
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
# Set primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
if ($SecondIPAddress)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
"Disable"
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
else
{
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Encrypted preffered, unencrypted allowed
if ($ComssOne)
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
else
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
}

25
src/Sophia_Script_for_Windows_11_ARM/Sophia.ps1

@ -1120,24 +1120,25 @@ SaveZoneInformation -Disable
# Выключить Windows Sandbox (значение по умолчанию). Применимо только к редакциям Professional, Enterprise и Education
# WindowsSandbox -Disable
<#
Enable DNS-over-HTTPS for IPv4
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
# Enable DNS-over-HTTPS using Cloudflare DNS
DNSoverHTTPS -Cloudflare
Включить DNS-over-HTTPS для IPv4
Действительные IPv4-адреса: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
#>
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
# Enable DNS-over-HTTPS using Google Public DNS
# Установить Google Public DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Google
# Enable DNS-over-HTTPS using Quad9
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Quad9
# Enable DNS-over-HTTPS using Comss.one
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -ComssOne
# Disable DNS-over-HTTPS for IPv4 (default value)
# Выключить DNS-over-HTTPS для IPv4 (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable DNS-over-HTTPS via Comss.one DNS server
# Включить DNS-over-HTTPS через DNS-сервер Comss.one
# https://www.comss.ru/page.php?id=7315
# DNSoverHTTPS -ComssOneDNS
# Enable Local Security Authority protection to prevent code injection
# Включить защиту локальной системы безопасности, чтобы предотвратить внедрение кода
# LocalSecurityAuthority -Enable

24
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Import-TabCompletion.ps1

@ -166,30 +166,6 @@ $Parameters = @{
}
}
# If a module command is DNSoverHTTPS
if ($Command -eq "DNSoverHTTPS")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get the valid IPv4 addresses array
# ((Get-Command -Name DNSoverHTTPS).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Select-Object -Unique
$ValidValues = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValue in $ValidValues)
{
$ValidValuesDescending = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValueDescending in $ValidValuesDescending)
{
# The "DNSoverHTTPS -Enable -PrimaryDNS x.x.x.x -SecondaryDNS x.x.x.x" construction
"DNSoverHTTPS -Enable -PrimaryDNS $ValidValue -SecondaryDNS $ValidValueDescending" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
}
"DNSoverHTTPS -Disable" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
"DNSoverHTTPS -ComssOneDNS" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
continue
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

2
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Private/PostActions.ps1

@ -114,8 +114,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

251
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Module/Sophia.psm1

@ -10733,31 +10733,40 @@ function WindowsSandbox
<#
.SYNOPSIS
DNS-over-HTTPS for IPv4
Configure DNS using DNS-over-HTTPS
.PARAMETER Enable
Enable DNS-over-HTTPS for IPv4
.PARAMETER Cloudflare
Enable DNS-over-HTTPS using Cloudflare DNS
.PARAMETER Google
Enable DNS-over-HTTPS using Google Public DNS
.PARAMETER Quad9
Enable DNS-over-HTTPS using Quad9 DNS
.PARAMETER ComssOne
Enable DNS-over-HTTPS using Comss.one DNS
.PARAMETER Disable
Disable DNS-over-HTTPS for IPv4
Set default ISP's DNS records
.EXAMPLE
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
DNSoverHTTPS -Cloudflare
.EXAMPLE Enable DNS-over-HTTPS via Comss.one DNS server
DNSoverHTTPS -ComssOneDNS
.EXAMPLE
DNSoverHTTPS -Google
.EXAMPLE
DNSoverHTTPS -Disable
DNSoverHTTPS -Quad9
.NOTES
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
.EXAMPLE
DNSoverHTTPS -ComssOne
.LINK
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.EXAMPLE
DNSoverHTTPS -Disable
.LINK
https://www.comss.ru/page.php?id=7315
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.NOTES
Machine-wide
@ -10769,38 +10778,31 @@ function DNSoverHTTPS
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
ParameterSetName = "Cloudflare"
)]
[switch]
$Enable,
$Cloudflare,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $SecondaryDNS)
})]
[string]
$PrimaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Google"
)]
[switch]
$Google,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $PrimaryDNS)
})]
[string]
$SecondaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Quad9"
)]
[switch]
$Quad9,
# https://www.comss.ru/page.php?id=7315
[Parameter(
Mandatory = $true,
ParameterSetName = "ComssOneDNS"
ParameterSetName = "ComssOne"
)]
[switch]
$ComssOneDNS,
$ComssOne,
[Parameter(
Mandatory = $true,
@ -10821,125 +10823,88 @@ function DNSoverHTTPS
$InterfaceGuids = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).InterfaceGuid)
}
switch ($PSCmdlet.ParameterSetName)
if ($Disable)
{
"Enable"
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Set a primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
# Encrypted preffered, unencrypted allowed
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
"ComssOneDNS"
else
{
# Resolve dns.comss.one to get its IP address to use
try
{
$ResolveComss = Resolve-DnsName -Name dns.comss.one -NoHostsFile -Verbose
}
catch [System.Net.WebException]
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -Verbose
Write-Error -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -ErrorAction SilentlyContinue
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
return
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Some ISPs block IP address resolving, and user get only one IP address
if ($ResolveComss.IPAddress.Count -eq 1)
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
}
else
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
$SecondIPAddress = $ResolveComss.IPAddress | Select-Object -Last 1
}
return
}
# Set a primary and secondary DNS servers
# https://www.comss.ru/page.php?id=7315
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
if ($SecondIPAddress)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
else
{
if ($SecondIPAddress)
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
switch ($PSCmdlet.ParameterSetName)
{
# https://developers.cloudflare.com/1.1.1.1/setup/windows/
"Cloudflare"
{
$PrimaryDNS = "1.1.1.1"
$SecondaryDNS = "1.0.0.1"
}
# https://developers.google.com/speed/public-dns/docs/using
"Google"
{
$PrimaryDNS = "8.8.8.8"
$SecondaryDNS = "8.8.4.4"
}
# https://quad9.net/service/service-addresses-and-features/
"Quad9"
{
$PrimaryDNS = "9.9.9.9"
$SecondaryDNS = "149.112.112.112"
}
# https://www.comss.ru/page.php?id=7315
"ComssOne"
{
$PrimaryDNS = "83.220.169.155"
$SecondaryDNS = "212.109.195.93"
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
# Set primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
if ($SecondIPAddress)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
"Disable"
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
else
{
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Encrypted preffered, unencrypted allowed
if ($ComssOne)
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
else
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
}

30
src/Sophia_Script_for_Windows_11_ARM_PowerShell_7/Sophia.ps1

@ -1120,23 +1120,25 @@ SaveZoneInformation -Disable
# Выключить Windows Sandbox (значение по умолчанию). Применимо только к редакциям Professional, Enterprise и Education
# WindowsSandbox -Disable
<#
Enable DNS-over-HTTPS for IPv4
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
# Enable DNS-over-HTTPS using Cloudflare DNS
# Установить Cloudflare DNS, используя DNS-over-HTTPS
DNSoverHTTPS -Cloudflare
Включить DNS-over-HTTPS для IPv4
Действительные IPv4-адреса: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
#>
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
# Enable DNS-over-HTTPS using Google Public DNS
# Установить Google Public DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Google
# Disable DNS-over-HTTPS for IPv4 (default value)
# Выключить DNS-over-HTTPS для IPv4 (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable DNS-over-HTTPS using Quad9
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Quad9
# Enable DNS-over-HTTPS via Comss.one DNS server
# Включить DNS-over-HTTPS через DNS-сервер Comss.one
# https://www.comss.ru/page.php?id=7315
# DNSoverHTTPS -ComssOneDNS
# Enable DNS-over-HTTPS using Comss.one
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -ComssOne
# Set default ISP's DNS records (default value)
# Установить DNS-записи вашего провайдера (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable Local Security Authority protection to prevent code injection
# Включить защиту локальной системы безопасности, чтобы предотвратить внедрение кода

24
src/Sophia_Script_for_Windows_11_LTSC_2024/Import-TabCompletion.ps1

@ -166,30 +166,6 @@ $Parameters = @{
}
}
# If a module command is DNSoverHTTPS
if ($Command -eq "DNSoverHTTPS")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get the valid IPv4 addresses array
# ((Get-Command -Name DNSoverHTTPS).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Select-Object -Unique
$ValidValues = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValue in $ValidValues)
{
$ValidValuesDescending = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValueDescending in $ValidValuesDescending)
{
# The "DNSoverHTTPS -Enable -PrimaryDNS x.x.x.x -SecondaryDNS x.x.x.x" construction
"DNSoverHTTPS -Enable -PrimaryDNS $ValidValue -SecondaryDNS $ValidValueDescending" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
}
"DNSoverHTTPS -Disable" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
"DNSoverHTTPS -ComssOneDNS" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
continue
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

2
src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Private/PostActions.ps1

@ -114,8 +114,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

251
src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1

@ -10152,31 +10152,40 @@ function WindowsSandbox
<#
.SYNOPSIS
DNS-over-HTTPS for IPv4
Configure DNS using DNS-over-HTTPS
.PARAMETER Enable
Enable DNS-over-HTTPS for IPv4
.PARAMETER Cloudflare
Enable DNS-over-HTTPS using Cloudflare DNS
.PARAMETER Google
Enable DNS-over-HTTPS using Google Public DNS
.PARAMETER Quad9
Enable DNS-over-HTTPS using Quad9 DNS
.PARAMETER ComssOne
Enable DNS-over-HTTPS using Comss.one DNS
.PARAMETER Disable
Disable DNS-over-HTTPS for IPv4
Set default ISP's DNS records
.EXAMPLE
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
DNSoverHTTPS -Cloudflare
.EXAMPLE Enable DNS-over-HTTPS via Comss.one DNS server
DNSoverHTTPS -ComssOneDNS
.EXAMPLE
DNSoverHTTPS -Google
.EXAMPLE
DNSoverHTTPS -Disable
DNSoverHTTPS -Quad9
.NOTES
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
.EXAMPLE
DNSoverHTTPS -ComssOne
.LINK
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.EXAMPLE
DNSoverHTTPS -Disable
.LINK
https://www.comss.ru/page.php?id=7315
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.NOTES
Machine-wide
@ -10188,38 +10197,31 @@ function DNSoverHTTPS
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
ParameterSetName = "Cloudflare"
)]
[switch]
$Enable,
$Cloudflare,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $SecondaryDNS)
})]
[string]
$PrimaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Google"
)]
[switch]
$Google,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $PrimaryDNS)
})]
[string]
$SecondaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Quad9"
)]
[switch]
$Quad9,
# https://www.comss.ru/page.php?id=7315
[Parameter(
Mandatory = $true,
ParameterSetName = "ComssOneDNS"
ParameterSetName = "ComssOne"
)]
[switch]
$ComssOneDNS,
$ComssOne,
[Parameter(
Mandatory = $true,
@ -10240,125 +10242,88 @@ function DNSoverHTTPS
$InterfaceGuids = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).InterfaceGuid)
}
switch ($PSCmdlet.ParameterSetName)
if ($Disable)
{
"Enable"
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Set a primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
# Encrypted preffered, unencrypted allowed
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
"ComssOneDNS"
else
{
# Resolve dns.comss.one to get its IP address to use
try
{
$ResolveComss = Resolve-DnsName -Name dns.comss.one -NoHostsFile -Verbose
}
catch [System.Net.WebException]
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -Verbose
Write-Error -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -ErrorAction SilentlyContinue
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
return
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Some ISPs block IP address resolving, and user get only one IP address
if ($ResolveComss.IPAddress.Count -eq 1)
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
}
else
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
$SecondIPAddress = $ResolveComss.IPAddress | Select-Object -Last 1
}
return
}
# Set a primary and secondary DNS servers
# https://www.comss.ru/page.php?id=7315
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
if ($SecondIPAddress)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
else
{
if ($SecondIPAddress)
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
switch ($PSCmdlet.ParameterSetName)
{
# https://developers.cloudflare.com/1.1.1.1/setup/windows/
"Cloudflare"
{
$PrimaryDNS = "1.1.1.1"
$SecondaryDNS = "1.0.0.1"
}
# https://developers.google.com/speed/public-dns/docs/using
"Google"
{
$PrimaryDNS = "8.8.8.8"
$SecondaryDNS = "8.8.4.4"
}
# https://quad9.net/service/service-addresses-and-features/
"Quad9"
{
$PrimaryDNS = "9.9.9.9"
$SecondaryDNS = "149.112.112.112"
}
# https://www.comss.ru/page.php?id=7315
"ComssOne"
{
$PrimaryDNS = "83.220.169.155"
$SecondaryDNS = "212.109.195.93"
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
# Set primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
if ($SecondIPAddress)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
"Disable"
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
else
{
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Encrypted preffered, unencrypted allowed
if ($ComssOne)
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
else
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
}

30
src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1

@ -1061,23 +1061,25 @@ SaveZoneInformation -Disable
# Выключить Windows Sandbox (значение по умолчанию). Применимо только к редакциям Professional, Enterprise и Education
# WindowsSandbox -Disable
<#
Enable DNS-over-HTTPS for IPv4
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
# Enable DNS-over-HTTPS using Cloudflare DNS
# Установить Cloudflare DNS, используя DNS-over-HTTPS
DNSoverHTTPS -Cloudflare
Включить DNS-over-HTTPS для IPv4
Действительные IPv4-адреса: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
#>
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
# Enable DNS-over-HTTPS using Google Public DNS
# Установить Google Public DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Google
# Disable DNS-over-HTTPS for IPv4 (default value)
# Выключить DNS-over-HTTPS для IPv4 (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable DNS-over-HTTPS using Quad9
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Quad9
# Enable DNS-over-HTTPS via Comss.one DNS server
# Включить DNS-over-HTTPS через DNS-сервер Comss.one
# https://www.comss.ru/page.php?id=7315
# DNSoverHTTPS -ComssOneDNS
# Enable DNS-over-HTTPS using Comss.one
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -ComssOne
# Set default ISP's DNS records (default value)
# Установить DNS-записи вашего провайдера (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable Local Security Authority protection to prevent code injection
# Включить защиту локальной системы безопасности, чтобы предотвратить внедрение кода

24
src/Sophia_Script_for_Windows_11_PowerShell_7/Import-TabCompletion.ps1

@ -190,30 +190,6 @@ $Parameters = @{
}
}
# If a module command is DNSoverHTTPS
if ($Command -eq "DNSoverHTTPS")
{
(Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"}
# Get the valid IPv4 addresses array
# ((Get-Command -Name DNSoverHTTPS).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues | Select-Object -Unique
$ValidValues = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValue in $ValidValues)
{
$ValidValuesDescending = @((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object {$_ -notmatch ":"}
foreach ($ValidValueDescending in $ValidValuesDescending)
{
# The "DNSoverHTTPS -Enable -PrimaryDNS x.x.x.x -SecondaryDNS x.x.x.x" construction
"DNSoverHTTPS -Enable -PrimaryDNS $ValidValue -SecondaryDNS $ValidValueDescending" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
}
}
"DNSoverHTTPS -Disable" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
"DNSoverHTTPS -ComssOneDNS" | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""}
continue
}
# If a module command is Set-Policy
if ($Command -eq "Set-Policy")
{

2
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Private/PostActions.ps1

@ -114,8 +114,6 @@ public static void PostMessage()
$Global:ScheduledTasks = $false
}
Write-Error -Message "ms-settings:startupapps" -ErrorAction SilentlyContinue
# Apply policies found in registry to re-build database database because gpedit.msc relies in its own database
if (Test-Path -Path "$env:TEMP\LGPO.txt")
{

251
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -10846,31 +10846,40 @@ function WindowsSandbox
<#
.SYNOPSIS
DNS-over-HTTPS for IPv4
Configure DNS using DNS-over-HTTPS
.PARAMETER Enable
Enable DNS-over-HTTPS for IPv4
.PARAMETER Cloudflare
Enable DNS-over-HTTPS using Cloudflare DNS
.PARAMETER Google
Enable DNS-over-HTTPS using Google Public DNS
.PARAMETER Quad9
Enable DNS-over-HTTPS using Quad9 DNS
.PARAMETER ComssOne
Enable DNS-over-HTTPS using Comss.one DNS
.PARAMETER Disable
Disable DNS-over-HTTPS for IPv4
Set default ISP's DNS records
.EXAMPLE
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
DNSoverHTTPS -Cloudflare
.EXAMPLE Enable DNS-over-HTTPS via Comss.one DNS server
DNSoverHTTPS -ComssOneDNS
.EXAMPLE
DNSoverHTTPS -Google
.EXAMPLE
DNSoverHTTPS -Disable
DNSoverHTTPS -Quad9
.NOTES
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
.EXAMPLE
DNSoverHTTPS -ComssOne
.LINK
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.EXAMPLE
DNSoverHTTPS -Disable
.LINK
https://www.comss.ru/page.php?id=7315
https://learn.microsoft.com/en-us/windows-server/networking/dns/doh-client-support
.NOTES
Machine-wide
@ -10882,38 +10891,31 @@ function DNSoverHTTPS
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
ParameterSetName = "Cloudflare"
)]
[switch]
$Enable,
$Cloudflare,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $SecondaryDNS)
})]
[string]
$PrimaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Google"
)]
[switch]
$Google,
[Parameter(Mandatory = $false)]
[ValidateScript({
# Isolate IPv4 IP addresses and check whether $PrimaryDNS is not equal to $SecondaryDNS
((@((Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters\DohWellKnownServers).PSChildName) | Where-Object -FilterScript {
($_ -as [IPAddress]).AddressFamily -ne "InterNetworkV6"
}) -contains $_) -and ($_ -ne $PrimaryDNS)
})]
[string]
$SecondaryDNS,
[Parameter(
Mandatory = $true,
ParameterSetName = "Quad9"
)]
[switch]
$Quad9,
# https://www.comss.ru/page.php?id=7315
[Parameter(
Mandatory = $true,
ParameterSetName = "ComssOneDNS"
ParameterSetName = "ComssOne"
)]
[switch]
$ComssOneDNS,
$ComssOne,
[Parameter(
Mandatory = $true,
@ -10934,125 +10936,88 @@ function DNSoverHTTPS
$InterfaceGuids = @((Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"}).InterfaceGuid)
}
switch ($PSCmdlet.ParameterSetName)
if ($Disable)
{
"Enable"
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Set a primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
# Encrypted preffered, unencrypted allowed
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
"ComssOneDNS"
else
{
# Resolve dns.comss.one to get its IP address to use
try
{
$ResolveComss = Resolve-DnsName -Name dns.comss.one -NoHostsFile -Verbose
}
catch [System.Net.WebException]
{
Write-Information -MessageData "" -InformationAction Continue
Write-Verbose -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -Verbose
Write-Error -Message (($Localization.NoResponse -f "https://dns.comss.one"), ($Localization.RestartFunction -f $MyInvocation.Line.Trim()) -join " ") -ErrorAction SilentlyContinue
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
return
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Some ISPs block IP address resolving, and user get only one IP address
if ($ResolveComss.IPAddress.Count -eq 1)
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
}
else
{
$FirstIPAddress = $ResolveComss.IPAddress | Select-Object -First 1
$SecondIPAddress = $ResolveComss.IPAddress | Select-Object -Last 1
}
return
}
# Set a primary and secondary DNS servers
# https://www.comss.ru/page.php?id=7315
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
if ($SecondIPAddress)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
else
{
if ($SecondIPAddress)
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress, $SecondIPAddress
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $FirstIPAddress
}
}
switch ($PSCmdlet.ParameterSetName)
{
# https://developers.cloudflare.com/1.1.1.1/setup/windows/
"Cloudflare"
{
$PrimaryDNS = "1.1.1.1"
$SecondaryDNS = "1.0.0.1"
}
# https://developers.google.com/speed/public-dns/docs/using
"Google"
{
$PrimaryDNS = "8.8.8.8"
$SecondaryDNS = "8.8.4.4"
}
# https://quad9.net/service/service-addresses-and-features/
"Quad9"
{
$PrimaryDNS = "9.9.9.9"
$SecondaryDNS = "149.112.112.112"
}
# https://www.comss.ru/page.php?id=7315
"ComssOne"
{
$PrimaryDNS = "83.220.169.155"
$SecondaryDNS = "212.109.195.93"
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$FirstIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
# Set primary and secondary DNS servers
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
else
{
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ServerAddresses $PrimaryDNS, $SecondaryDNS
}
if ($SecondIPAddress)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Force
}
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondIPAddress" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS"))
{
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Force
}
"Disable"
if (-not (Test-Path -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS"))
{
# Determining whether Hyper-V is enabled
if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent)
{
# Configure DNS servers automatically
Get-NetRoute | Where-Object -FilterScript {$_.DestinationPrefix -eq "0.0.0.0/0"} | Get-NetAdapter | Where-Object -FilterScript {$_.Status -eq "Up"} | Set-DnsClientServerAddress -ResetServerAddresses
}
else
{
# Configure DNS servers automatically
Get-NetAdapter -Physical | Where-Object -FilterScript {$_.Status -eq "Up"} | Get-NetIPInterface -AddressFamily IPv4 | Set-DnsClientServerAddress -ResetServerAddresses
}
New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Force
}
foreach ($InterfaceGuid in $InterfaceGuids)
{
Remove-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh" -Recurse -Force -ErrorAction Ignore
}
# Encrypted preffered, unencrypted allowed
if ($ComssOne)
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 2 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohTemplate -PropertyType String -Value https://dns.comss.one/dns-query -Force
}
else
{
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$PrimaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$InterfaceGuid\DohInterfaceSettings\Doh\$SecondaryDNS" -Name DohFlags -PropertyType QWord -Value 5 -Force
}
}

30
src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

@ -1124,23 +1124,25 @@ SaveZoneInformation -Disable
# Выключить Windows Sandbox (значение по умолчанию). Применимо только к редакциям Professional, Enterprise и Education
# WindowsSandbox -Disable
<#
Enable DNS-over-HTTPS for IPv4
The valid IPv4 addresses: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
# Enable DNS-over-HTTPS using Cloudflare DNS
# Установить Cloudflare DNS, используя DNS-over-HTTPS
DNSoverHTTPS -Cloudflare
Включить DNS-over-HTTPS для IPv4
Действительные IPv4-адреса: 1.0.0.1, 1.1.1.1, 149.112.112.112, 8.8.4.4, 8.8.8.8, 9.9.9.9
#>
DNSoverHTTPS -Enable -PrimaryDNS 1.0.0.1 -SecondaryDNS 1.1.1.1
# Enable DNS-over-HTTPS using Google Public DNS
# Установить Google Public DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Google
# Disable DNS-over-HTTPS for IPv4 (default value)
# Выключить DNS-over-HTTPS для IPv4 (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable DNS-over-HTTPS using Quad9
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -Quad9
# Enable DNS-over-HTTPS via Comss.one DNS server
# Включить DNS-over-HTTPS через DNS-сервер Comss.one
# https://www.comss.ru/page.php?id=7315
# DNSoverHTTPS -ComssOneDNS
# Enable DNS-over-HTTPS using Comss.one
# Установить Google DNS, используя DNS-over-HTTPS
# DNSoverHTTPS -ComssOne
# Set default ISP's DNS records (default value)
# Установить DNS-записи вашего провайдера (значение по умолчанию)
# DNSoverHTTPS -Disable
# Enable Local Security Authority protection to prevent code injection
# Включить защиту локальной системы безопасности, чтобы предотвратить внедрение кода

Loading…
Cancel
Save