Bigfix fixlet or task to change server DNS?

Hello, I am new to bigfix, and I am looking to see if someone can point me to the right direction? is there a fixlet or task or maybe someone can help me with an action script on how to changing DNS on a server or workstation? Thanks!

This is doable, you can try below action script to achieve this:

//Capture the require details
action parameter query "NICName" with description "Provide NIC Name which you would like to update for DNS entries"

action parameter query "PrimaryDNSIPAddress" with description "Provide Primary DNS IP Address"

action parameter query "SecondaryDNSIPAddress" with description "Provide Secondary DNS IP Address"

//Set Primary DNS IP
waithidden cmd.exe /c "netsh interface ipv4 set dnsservers "{parameter "NICName" of action}" static {parameter "PrimaryDNSIPAddress" of action} primary"

//Add Secondary DNS IP
waithidden cmd.exe /c "netsh interface ipv4 add dnsservers "{parameter "NICName" of action}" {parameter "SecondaryDNSIPAddress" of action} index=2"

waithidden cmd.exe /c "ipconfig /flushdns" 
waithidden cmd.exe /c "ipconfig /registerdns"
2 Likes

Thanks! I will give this a try.

This is something i built out knowing what the OLD DNS server was and using that to replace - inplace with the new DNS servers.

  • I have outputs being written as i also built analysis and other tasks to validate connectivity and responses to DNS queries before changing the clients. Aka some systems behind the firewalls cant access or shouldnt access the same DNS servers as the rest of my world.

Powershell clips from: How To Safely Change DNS Client Settings - Easy365Manager

This is run using a task with script type: powershell

$OldDNS = (‘10.15.2.16’, ‘10.15.2.15’, ‘10.15.1.117’, ‘10.15.1.117’)
$NewDNS = (‘10.220.255.254’, ‘10.250.255.254’)
$ScriptBlockRead = {Get-NetAdapter | Get-DnsClientServerAddress | ? {$.ServerAddresses -like $OldDNS[0] -OR $.ServerAddresses -like $OldDNS[1] -OR $.ServerAddresses -like $OldDNS[2] -OR $.ServerAddresses -like $OldDNS[3] }}
$ScriptBlockWrite = {Get-NetAdapter | Get-DnsClientServerAddress | ? {$.ServerAddresses -like $OldDNS[0] -OR $.ServerAddresses -like $OldDNS[1] -OR $.ServerAddresses -like $OldDNS[2] -OR $.ServerAddresses -like $OldDNS[3]} | Set-DnsClientServerAddress -ServerAddresses $NewDNS}

$Adapter = Invoke-Command  -ScriptBlock $ScriptBlockRead -ErrorAction SilentlyContinue
If ($Adapter){
    $Output =  $Adapter.InterfaceAlias + ";" + $Adapter.InterfaceIndex + ";" + $Adapter.ServerAddresses
 #   Write-Host $Output
    Write-Output  $Output >> C:\Windows\Temp\dns_update.txt
    Invoke-Command -ScriptBlock $ScriptBlockWrite
	Write-Output "Updated" >> C:\Windows\Temp\dns_update.txt
   }
Else {
    Write-Host Skipping
	Write-Output "Skipping" >> C:\Windows\Temp\dns_update.txt
}
1 Like