mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-17 10:17:44 -06:00
Merge 706f73923a
into bea87e8ccf
This commit is contained in:
commit
0d528b7a77
@ -128,7 +128,9 @@ If you encounter any challenges or problems with the script, I kindly request th
|
||||
|
||||
## Contribute Code
|
||||
|
||||
To contribute new code, please ensure that it is submitted to the **TEST BRANCH**. Please note that merges will not be performed directly on the MAIN branch.
|
||||
If you adding, changing, or deleting an Application... submit to **APPLICATIONS branch**. We batch these in at the end of the month.
|
||||
|
||||
If doing a code change and you can submit a PR to main branch, but I am very selective about these. Do not use a code formatter, massive amounts of line changes, and make multiple feature changes. EACH FEATURE CHANGE SHOULD BE IT'S OWN Pull Request!
|
||||
|
||||
When creating pull requests, it is essential to thoroughly document all changes made. This includes documenting any additions made to the tweaks section and ensuring that corresponding undo measures are in place to remove the newly added tweaks if necessary. Failure to adhere to this format may result in denial of the pull request. Additionally, comprehensive documentation is required for all code changes. Any code lacking sufficient documentation may also be denied.
|
||||
|
||||
|
@ -2394,7 +2394,7 @@
|
||||
],
|
||||
"InvokeScript": [
|
||||
"
|
||||
Write-Host \"Remove Popilot\"
|
||||
Write-Host \"Remove Copilot\"
|
||||
dism /online /remove-package /package-name:Microsoft.Windows.Copilot
|
||||
"
|
||||
],
|
||||
@ -3043,11 +3043,12 @@
|
||||
},
|
||||
"WPFchangedns": {
|
||||
"Content": "DNS",
|
||||
"Name": "DNS",
|
||||
"category": "z__Advanced Tweaks - CAUTION",
|
||||
"panel": "1",
|
||||
"Order": "a040_",
|
||||
"Type": "Combobox",
|
||||
"ComboItems": "Default DHCP Google Cloudflare Cloudflare_Malware Cloudflare_Malware_Adult Level3 Open_DNS Quad9"
|
||||
"ComboItems": "Custom DHCP Google Cloudflare Cloudflare_Malware Cloudflare_Malware_Adult Level3 Open_DNS Quad9"
|
||||
},
|
||||
"WPFTweaksbutton": {
|
||||
"Content": "Run Tweaks",
|
||||
|
70
functions/private/Get-WinUtilDNS.ps1
Normal file
70
functions/private/Get-WinUtilDNS.ps1
Normal file
@ -0,0 +1,70 @@
|
||||
function Get-WinUtilDNS {
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Gets the DNS of all interfaces that are in the "Up" state. It will set the default state of the ComboBox to the DNS provider that is currently set on the interface.
|
||||
|
||||
#>
|
||||
|
||||
Try {
|
||||
$Adapters = Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
|
||||
|
||||
# Get all DNS providers and their server addresses
|
||||
$dnsProviders = $sync.configs.dns.PSObject.Properties | ForEach-Object {
|
||||
@{
|
||||
Name = $_.Name
|
||||
Primary = $_.Value.Primary
|
||||
Secondary = $_.Value.Secondary
|
||||
}
|
||||
}
|
||||
|
||||
# Initialize a variable to hold the matched provider
|
||||
$matchedProvider = $null
|
||||
$global:previousDnsSettings = @()
|
||||
|
||||
Foreach ($Adapter in $Adapters) {
|
||||
Try {
|
||||
# Get the current DNS server addresses
|
||||
$currentDnsServers = (Get-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -AddressFamily IPv4).ServerAddresses
|
||||
|
||||
# Save the current DNS server addresses
|
||||
$global:previousDnsSettings += @{
|
||||
AdapterName = $Adapter.Name
|
||||
DnsAddresses = $currentDnsServers
|
||||
}
|
||||
|
||||
# Check if the current DNS servers match any of the providers
|
||||
$matchingProvider = $dnsProviders | Where-Object {
|
||||
$currentDnsServers -contains $_.Primary -and $currentDnsServers -contains $_.Secondary
|
||||
}
|
||||
|
||||
if ($matchingProvider) {
|
||||
# If this is the first match, set the matchedProvider
|
||||
if (-not $matchedProvider) {
|
||||
$matchedProvider = $matchingProvider.Name
|
||||
} elseif ($matchedProvider -ne $matchingProvider.Name) {
|
||||
# If there is a mismatch in providers, set to Custom
|
||||
$matchedProvider = "Custom"
|
||||
break
|
||||
}
|
||||
} else {
|
||||
# If no match is found, set to Custom
|
||||
$matchedProvider = "Custom"
|
||||
break
|
||||
}
|
||||
} Catch {
|
||||
Write-Warning "Failed to process adapter: $($Adapter.Name)"
|
||||
Write-Warning $_.Exception.Message
|
||||
Write-Warning $_.Exception.StackTrace
|
||||
}
|
||||
}
|
||||
|
||||
# Set the text of $sync["WPFchangedns"] to the result text
|
||||
$sync["WPFchangedns"].text = if ($matchedProvider) { $matchedProvider } else { "Custom" }
|
||||
}
|
||||
Catch {
|
||||
Write-Warning "Unable to get DNS Provider due to an unhandled exception"
|
||||
Write-Warning $_.Exception.Message
|
||||
Write-Warning $_.Exception.StackTrace
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ function Invoke-WinUtilNumLock {
|
||||
Write-Host "Disabling Numlock on startup"
|
||||
$value = 0
|
||||
}
|
||||
$Path = "HKCU:\Control Panel\Keyboard"
|
||||
$Path = "HKU:\.Default\Control Panel\Keyboard"
|
||||
Set-ItemProperty -Path $Path -Name InitialKeyboardIndicators -Value $value
|
||||
}
|
||||
Catch [System.Security.SecurityException] {
|
||||
|
@ -12,23 +12,36 @@ function Set-WinUtilDNS {
|
||||
|
||||
#>
|
||||
param($DNSProvider)
|
||||
if($DNSProvider -eq "Default"){return}
|
||||
|
||||
$dnsProviders = $sync.configs.dns.PSObject.Properties.Name
|
||||
|
||||
Try{
|
||||
$Adapters = Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
|
||||
Write-Host "Ensuring DNS is set to $DNSProvider on the following interfaces"
|
||||
Write-Host $($Adapters | Out-String)
|
||||
|
||||
Foreach ($Adapter in $Adapters){
|
||||
if($DNSProvider -eq "DHCP"){
|
||||
Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ResetServerAddresses
|
||||
}
|
||||
Else{
|
||||
Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ServerAddresses ("$($sync.configs.dns.$DNSProvider.Primary)", "$($sync.configs.dns.$DNSProvider.Secondary)")
|
||||
switch ($DNSProvider) {
|
||||
"DHCP" {
|
||||
Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ResetServerAddresses
|
||||
}
|
||||
"Custom" {
|
||||
$savedSettings = $global:previousDnsSettings | Where-Object { $_.AdapterName -eq $Adapter.Name }
|
||||
|
||||
if ($savedSettings) {
|
||||
# Set the DNS server addresses for the adapter to the saved addresses
|
||||
Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ServerAddresses $savedSettings.DnsAddresses
|
||||
}
|
||||
}
|
||||
default {
|
||||
Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ServerAddresses ("$($sync.configs.dns.$DNSProvider.Primary)", "$($sync.configs.dns.$DNSProvider.Secondary)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to set DNS Provider due to an unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
Write-Warning $_.Exception.Message
|
||||
Write-Warning $_.Exception.StackTrace
|
||||
}
|
||||
}
|
||||
|
@ -434,6 +434,8 @@ $sync["CheckboxFilter"].Add_TextChanged({
|
||||
$label.Visibility = "Collapsed"}
|
||||
})
|
||||
|
||||
Get-WinUtilDNS
|
||||
|
||||
# Define event handler for button click
|
||||
$sync["SettingsButton"].Add_Click({
|
||||
Write-Debug "SettingsButton clicked"
|
||||
|
@ -1987,7 +1987,7 @@ function Invoke-WinUtilNumLock {
|
||||
Write-Host "Disabling Numlock on startup"
|
||||
$value = 0
|
||||
}
|
||||
$Path = "HKCU:\Control Panel\Keyboard"
|
||||
$Path = "HKU:\.Default\Control Panel\Keyboard"
|
||||
Set-ItemProperty -Path $Path -Name InitialKeyboardIndicators -Value $value
|
||||
}
|
||||
Catch [System.Security.SecurityException] {
|
||||
@ -10950,7 +10950,7 @@ $sync.configs.tweaks = '{
|
||||
],
|
||||
"InvokeScript": [
|
||||
"
|
||||
Write-Host \"Remove Popilot\"
|
||||
Write-Host \"Remove Copilot\"
|
||||
dism /online /remove-package /package-name:Microsoft.Windows.Copilot
|
||||
"
|
||||
],
|
||||
|
@ -40,7 +40,7 @@
|
||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
|
||||
<Label Content="DNS" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<ComboBox Name="WPFchangedns" Height="32" Width="186" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,5">
|
||||
<ComboBoxItem IsSelected="True" Content="Default"/>
|
||||
<ComboBoxItem IsSelected="True" Content="Custom"/>
|
||||
<ComboBoxItem Content="DHCP"/>
|
||||
<ComboBoxItem Content="Google"/>
|
||||
<ComboBoxItem Content="Cloudflare"/>
|
||||
|
Loading…
Reference in New Issue
Block a user