This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.

Set-NetworkAdapterDNS

Synopsis

Sets the DNS server addresses, suffix and registration options of a network adapter on a local or remote computer.

Syntax

  • Set-NetworkAdapterDNS [-Name] [-DNSServer] [-DNSSuffix] [-EnableDNSRegistration] [-DisabledDNSRegistration] [-ComputerName] [-Credential]
  • Set-NetworkAdapterDNS [-MACAddress] [-DNSServer] [-DNSSuffix] [-EnableDNSRegistration] [-DisabledDNSRegistration] [-ComputerName] [-Credential]

Description

The Set-NetworkAdapterDNS cmdlet is used to set the DNS server addresses, DNS suffix and DNS domain registration options used by a network adapter on a local or remote computer. Adapters can be identified by name or MAC address.

Parameters

  • Name The name of the network adapter to configure. This parameter cannot be used when the MACAddress parameter has been specified.
  • MACAddress The MAC address of the network adapter to configure. This parameter cannot be used when the name parameter has been specified.
  • DNSServer The DNS server address to assign to the network adapter. When specifying multiple addresses they will be assigned priority based on the order in which they are presented to the cmdlet, the first address being the primary DNS server, the second the secondary, etc.
  • DNSSuffix The DNS suffix to be assigned to the network adapter.
  • EnableDNSRegistration Enable DNS registration on the network adapter. This parameter cannot be used when the DisableDNSRegistration parameter has been specified.
  • DisableDNSRegistration Disable DNS registration on the network adapter. This parameter cannot be used when the EnableDNSRegistration parameter has been specified.
  • ComputerName The computer against which to run the cmdlet. By default this cmdlet will be populated with the name of the local computer.
  • Credential The credentials under which to run the cmdlet. By default this cmdlet will run as the current user. Using this parameter and the Get-PSCredential cmdlet you can specify an alternate set of credentials under which to execute this command.

Inputs

Set-NetworkAdapterDNS accepts the output of Get-NetworkAdapter as an input object. The Name, MACAddress and ComputerName parameters each accept pipeline input by property name.

Outputs

Set-NetworkAdapterDNS makes changes directly to Windows and does not output any Powershell objects.

Notes

The Set-NetworkAdapterDNS cmdlet requires that the Remote Registry and RPC services are started on the computer it is trying to access and that DNS services are available to resolve target host names.

Example 1

This command will set the network adapter "Local Area Connection" to use 192.168.0.44 as its DNS server:

C:\PS> Set-NetworkAdapterDNS "Local Area Connection" -DNSServer 192.168.0.44

Example 2

Set-NetworkAdapterDNS can also be used to set multiple DNS servers. This command will set the adapter "Local Area Connection" on the remote computer PC01 to use 192.168.0.44 as its primary DNS server and 192.168.0.45 as its secondary:

C:\PS> Set-NetworkAdapterDNS "Local Area Connection" -DNSServer 192.168.0.44, 192.168.0.45 -Computer PC01

Example 3

Set-NetworkAdapterDNS can also in conjunction with Get-NetworkAdapter. This command copies the DNS servers used by the local computer and sets them on adapters of the same name on remote computer PC01:

C:\PS> Get-NetworkAdapter | Set-NetworkAdapterDNS -Computer PC01

Example 4

Set-NetworkAdapterDNS can be used to configure the DNS suffix and DNS registration settings for an adapter. This command will set the DNS suffix for the adapter to amadeupcompany.com and enable DNS registration:

C:\PS> Set-NetworkAdapterDNS "Local Area Connection" -DNSSuffix amadeupcompany.com -EnableDNSRegistration