Export (0) Print
Expand All
Expand Minimize

Set-DnsServer

Windows Server 2012 R2 and Windows 8.1

Updated: May 20, 2014

Applies To: Windows 8.1, Windows PowerShell 4.0, Windows Server 2012 R2

Set-DnsServer

Overwrites a DNS server configuration.

Syntax

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




Detailed 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.

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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CimSession<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.


Aliases

Session

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String>

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.


Aliases

Cn

Required?

false

Position?

named

Default Value

none

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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Force

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


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InputObject<CimInstance>

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


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

True (ByValue)

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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

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

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.


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"

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

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.


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

Example 3: Migrate DNS server configuration by using IP addresses

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.


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

Example 4: Create a file-backed primary zone

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.


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

Related topics

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft