Saturday 23 March 2013

Windows Server 2012 Server Core–Playing with Network Card using PowerShell Part 2

Setting DNS server First find the InterfaceAlias or InterfaceIndex using the “Get-NetIPInterface” of the desired interface. Now use the following command to set the DNS server IP address
Set-DNSClientServerAddress –InterfaceIndex <InterfaceIndex as UInt32> -ServerAddresses <Comma separated list of IP Address as String>
                                                                 or
Set-DNSClientServerAddress -InterfaceAlias <InterfaceAlias as String> -ServerAddresses <Comma separated list of IP Address as String>
Before Setting DNS
  After Setting DNS
Removing DNS server First find the InterfaceAlias or InterfaceIndex using the “Get-NetIPInterface” of the desired interface. Now use the following command to reset the DNS server IP address
Set-DnsClientServerAddress –InterfaceIndex <InterfaceIndex as UInt32> -ResetServerAddresses
                                       or
Set-DnsClientServerAddress -InterfaceAlias <InterfaceAlias as String> –ResetServerAddresses
After resetting DNS
Removing IP Address First find the InterfaceAlias or InterfaceIndex using the “Get-NetIPInterface” of the desired interface. Now use the following command to remove just the IP address from the interface
Remove-NetIPAddress –InterfaceIndex <InterfaceIndex as UInt32>
                                 or
Remove-NetIPAddress -InterfaceAlias <InterfaceAlias as String>
 If you want to remove the IPAddress without confirmation just use the option “-Confirm:$false” at the end of above command, of course without quotes. Now if you want to remove IPAddress and default gateway then use the following command. Use “-Confirm:$false” part only if you don't want questions for confirmation.
Remove-NetIPAddress –InterfaceIndex <InterfaceIndex as UInt32> -IPAddress <IPAddress as String> -DefaultGateway <DefaultGateway as String> [-Confirm:$false]
                                                                       or
Remove-NetIPAddress -InterfaceAlias <InterfaceAlias as String> -IPAddress <IPAddress as String> -DefaultGateway <DefaultGateway as String> [-Confirm:$false]
 Viewing DNS cache Use the following command to view the DNS cache
Get-DNSClientCache
 Clearing DNS Cache Use the following command to clear the DNS Cache
Clear-DNSClientCache

   

No comments:

Post a Comment