Skip to content

Instantly share code, notes, and snippets.

@gioxx
Created March 22, 2022 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gioxx/c1d0a234983e863344147d1886ec0e10 to your computer and use it in GitHub Desktop.
Save gioxx/c1d0a234983e863344147d1886ec0e10 to your computer and use it in GitHub Desktop.
Rimuove il suffisso DNS inserito in maniera forzata dai router Telecom Italia sulle schede di rete Windows - https://gioxx.org/tag/powershell/
<#
Remove homenet.telecomitalia.it from Windows DNS Suffix
GSolone 22/3/22
Credits:
https://superuser.com/a/1507551
https://docs.microsoft.com/en-us/powershell/module/dnsclient/set-dnsclientglobalsetting?view=windowsserver2022-ps&viewFallbackFrom=win10-ps
https://www.mssqltips.com/sqlservertip/5459/how-to-modify-the-global-dns-configuration-on-servers-using-powershell/
https://adamtheautomator.com/powershell-replace/
#>
try {
$dnsCGSetting = Get-DnsClientGlobalSetting
if($dnsCGSetting.SuffixSearchList.Contains('homenet.telecomitalia.it')) {
$dnsCGClean = $dnsCGSetting.SuffixSearchList.replace('homenet.telecomitalia.it','')
Set-DnsClientGlobalSetting -SuffixSearchList $dnsCGClean
Write-Host "Telecom suffix removed."
} else {
Write-Host "No Telecom suffix found."
}
} catch {
Write-Host "An error occurred:"
Write-Host $_.ScriptStackTrace
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment