SynopsisAdds the specified DNS server address to the configuration of a network adapter on a local or remote computer.
- Add-NetworkAdapterDNS [-Name] [-DNSServer] [-Position] [-ComputerName] [-Credential]
- Add-NetworkAdapterDNS [-MACAddress] [-DNSServer] [-Position] [-ComputerName] [-Credential]
DescriptionThe Add-NetworkAdapterDNS cmdlet is used to add DNS server addresses to the configuration of a network adapter on a local or remote computer. Adapters can be identified by name or MAC address.
- Name The name of the network adapter to configure. This parameter cannot be used when the MACAddress parameter has been specified.
- DNSServer The DNS server to add.
- Position The position in which to add the DNS server address. If the parameter is not specified or an invalid position is given (such as position 4 on an adapter with only primary and secondary DNS addresses configured) the address will be added with the lowest valid position.
- MACAddress The MAC address of the network adapter to configure. This parameter cannot be used when the name 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.
InputsAdd-NetworkAdapterDNS accepts the output of Get-NetworkAdapter as an input object. The Name, MACAddress and ComputerName parameters each accept pipeline input by property name.
OutputsAdd-NetworkAdapterDNS makes changes directly to Windows and does not output any Powershell objects.
NotesThe Add-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 1This command will add the DNS server address 126.96.36.199 to adapter "Local Area Connection". Because the position parameter has not been specified the DNS server will be given the lowest priority:
C:\PS>Add-NetworkAdapterDNS "Local Area Connection" -DNSServer 192.168.1.44
Example 2This command will add the DNS server address 188.8.131.52 to adapter "Local Area Connection". The position parameter has been used to specify this address as the secondary DNS server.
C:\PS>Add-NetworkAdapterDNS "Local Area Connection" -DNSServer 192.168.1.45 -Position 2
Example 3Add-NetworkAdapterDNS can be used in conjunction with the Get-NetworkAdapter cmdlet. In this example, Get-NetworkAdapter fetches all the network adapters on the remote computer PC01 and Add-NetworkAdapterDNS adds 184.108.40.206 as the new primary DNS server on each adapter.
C:\PS>Get-NetworkAdapter | Add-NetworkAdapterDNS -DNSServer 192.168.1.45 -Position 1