Sometimes you need to update multiple computers with proper DNS settings. Instead of doing this one by one manually you can automate it so it can be done in one go, from a single PowerShell script. Simple, yet very effective.
Sometimes you need to update multiple computers with proper DNS settings. Instead of doing this one by one manually you can automate it so it can be done in one go, from a single PowerShell script. Simple, yet very effective.
This is a basic script that sets the DNS Server IP Addresses on Network Card based on its name.
function Set-DnsServerIpAddress { param( [string] $ComputerName, [string] $NicName, [string] $IpAddresses ) if (Test-Connection -ComputerName $ComputerName -Count 2 -Quiet) { Invoke-Command -ComputerName $ComputerName -ScriptBlock { param ($ComputerName, $NicName, $IpAddresses) write-host "Setting on $ComputerName on interface $NicName a new set of DNS Servers $IpAddresses" Set-DnsClientServerAddress -InterfaceAlias $NicName -ServerAddresses $IpAddresses } -ArgumentList $ComputerName, $NicName, $IpAddresses } else { write-host "Can't access $ComputerName. Computer is not online." } }
The usage is quite simple:
# Where $ServerName can be set as needed # Where Service is the name of the Network Card (takes wildcard) # Where IpAddresses are given in brackets Set-DnsServerIpAddress -ComputerName $ServerName -NicName "Service*" -IpAddresses '8.8.8.8','8.8.4.4','8.8.8.1'
This post was last modified on November 11, 2018 01:16
Today, I made the decision to upgrade my test environment and update the version of…
Have you ever looked at your Active Directory and wondered, "Why do I still have…
Active Directory replication is a critical process that ensures the consistent and up-to-date state of…
Hey there! Today, I wanted to introduce you to one of the small but excellent…
Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…
In today's digital age, the ability to create compelling and informative HTML reports and documents…