Edit

Share via


Set-DnsServer

Overwrites a DNS server configuration.

Syntax

Set-DnsServer
   [-InputObject] <CimInstance>
   [-ComputerName <String>]
   [-Force]
   [-CreateFileBackedPrimaryZones]
   [-PassThru]
   [-CimSession <CimSession[]>]
   [-ThrottleLimit <Int32>]
   [-AsJob]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Set-DnsServer cmdlet uses an input object to overwrite a specified Domain Name System (DNS) server configuration. You can generate the input object by using an XML file that is exported by using any of the following cmdlets: Get-DnsServer, Export-Clixml, or Import-Clixml.

For more information about Export-Clixml, see Export-Clixml. For more information about Import-Clixml, see Import-Clixml.

Examples

Example 1: Overwrite a DNS server configuration by using an input object

PS C:\> Get-DnsServer -ComputerName "DNSServer13.Contoso.com" | Export-Clixml -Path "c:\DnsServerConfig.xml"
PS C:\> $x = Import-Clixml "c:\DnsServerConfig.xml"
PS C:\> Set-DnsServer -InputObject $x -ComputerName "DNSServer22.Contoso.com"

This set of commands uses an input object to overwrite a DNS server configuration.

As shown in the code block, the first command gets DNS server configuration by using the Get-DnsServer cmdlet. It then pipes the information to the Export-Clixml cmdlet, which exports the data into an XML file.

The second command gets and stores the XML file data in variable $x.

The third command uses the data that is stored in variable $x to overwrite an existing DNS server configuration.

Example 2: Set DNS server configuration by using the Cimsession parameter

PS C:\> Get-DnsServer -CimSession 172.22.50.137 | Set-DnsServer

This command gets DNS server configuration from a server that has an IP address of 172.22.50.137 and applies it to the server on which the Set-DnsServer cmdlet is run.

Example 3: Migrate DNS server configuration by using IP addresses

PS C:\> Get-DnsServer -CimSession 172.22.50.137 | Set-DnsServer -ComputerName 172.22.50.138

This command migrates DNS server configuration from a server that has an IP address of 172.22.50.137 to a server that has an IP address of 172.22.50.138.

Example 4: Create a file-backed primary zone

PS C:\> Get-DnsServer -CimSession 172.22.50.137 | Set-DnsServer -CreateFileBackedPrimaryZones

This command creates file-backed primary zones on the specified local DNS server. The file that contains resource records must exist in the %windir%\system32\dns directory.

Parameters

-AsJob

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.

The cmdlet immediately returns an object that represents the job and then displays the command prompt. You can continue to work in the session while the job completes. To manage the job, use the *-Job cmdlets. To get the job results, use the Receive-Job cmdlet.

For more information about Windows PowerShell background jobs, see about_Jobs.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CimSession

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

Type:CimSession[]
Aliases:Session
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ComputerName

Specifies a DNS server. The acceptable values for this parameter are: an IP v4 address; an IP v6 address; any other value that resolves to an IP address, such as a fully qualified domain name (FQDN), host name, or NETBIOS name.

Type:String
Aliases:Cn
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CreateFileBackedPrimaryZones

Indicates that you must create new file-backed primary zones in the input object. The files that contains the resource records must exist in the %windir%\system32\dns directory.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Overrides the default confirmation setting before the cmdlet performs the action.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

Specifies the input to this cmdlet. You can use this parameter, or you can pipe the input to this cmdlet.

Type:CimInstance
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ThrottleLimit

Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.

Type:Int32
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Outputs

CimInstance