An older thread discussed the usage of Set-DNSServerSetting:
The command help is unfortunately also not very helpful:
https://github.com/MicrosoftDocs/windows-powershell-docs/blob/master/docset/winserver2019-ps/dnsserver/Set-DnsServerSetting.md
After figuring out how the command can be used, it's simple and straight forward. It would be great if MS adds better examples.
Create a cim Instance to hold the values which should be set:
$DNSSetting = New-CimInstance -Namespace root/Microsoft/Windows/Dns -ClassName DnsServerSetting
-Property @{
LocalNetPriority =$True
LocalNetPriorityMask = [uint32]0x0000ffff
} -ClientOnlyPass it to the Set-DNSServerSetting
Set-DnsServerSetting $DNSSetting
Alternatively you can pipe the CimInstance directly:
New-CimInstance -Namespace root/Microsoft/Windows/Dns -ClassName DnsServerSetting -Property @{ LocalNetPriority =$True; LocalNetPriorityMask = [uint32]0x0000ffff } -ClientOnly | Set-DnsServerSetting
Important: you need to use the correct type (ie [int] is not eq [uint32]). To get all possible types, run the following command:
Get-DnsServerSetting -All | gm
WARNING: EnableRegistryBoot not applicable on DNS Server UB1TECDC01 version.
TypeName: Microsoft.Management.Infrastructure.CimInstance#root/Microsoft/Windows/DNS/DnsServerSetting
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object ICloneable.Clone()
Dispose Method void Dispose(), void IDisposable.Dispose()
Equals Method bool Equals(System.Object obj)
GetCimSessionComputerName Method string GetCimSessionComputerName()
GetCimSessionInstanceId Method guid GetCimSessionInstanceId()
GetHashCode Method int GetHashCode()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo...
GetType Method type GetType()
ToString Method string ToString()
AddressAnswerLimit Property uint32 AddressAnswerLimit {get;set;}
AdminConfigured Property bool AdminConfigured {get;set;}
AllIPAddress Property string[] AllIPAddress {get;}
AllowCNameAtNs Property bool AllowCNameAtNs {get;set;}
AllowReadOnlyZoneTransfer Property bool AllowReadOnlyZoneTransfer {get;set;}
AllowUpdate Property bool AllowUpdate {get;set;}
AppendMsZoneTransferTag Property bool AppendMsZoneTransferTag {get;set;}
AutoCacheUpdate Property bool AutoCacheUpdate {get;set;}
AutoConfigFileZones Property uint32 AutoConfigFileZones {get;set;}
AutoCreateDelegation Property uint32 AutoCreateDelegation {get;set;}
BindSecondaries Property bool BindSecondaries {get;set;}
BootMethod Property uint32 BootMethod {get;set;}
BuildNumber Property uint32 BuildNumber {get;}
ComputerName Property string ComputerName {get;}
DeleteOutsideGlue Property bool DeleteOutsideGlue {get;set;}
DisableAutoReverseZone Property bool DisableAutoReverseZone {get;set;}
DomainDirectoryPartitionBaseName Property string DomainDirectoryPartitionBaseName {get;}
DsAvailable Property bool DsAvailable {get;}
EnableDirectoryPartitions Property bool EnableDirectoryPartitions {get;set;}
EnableDnsSec Property bool EnableDnsSec {get;set;}
EnableDuplicateQuerySuppression Property bool EnableDuplicateQuerySuppression {get;set;}
EnableIPv6 Property bool EnableIPv6 {get;set;}
EnableIQueryResponseGeneration Property bool EnableIQueryResponseGeneration {get;set;}
EnableOnlineSigning Property bool EnableOnlineSigning {get;set;}
EnableRegistryBoot Property uint32 EnableRegistryBoot {get;set;}
EnableRsoForRodc Property bool EnableRsoForRodc {get;set;}
EnableSendErrorSuppression Property bool EnableSendErrorSuppression {get;set;}
EnableUpdateForwarding Property bool EnableUpdateForwarding {get;set;}
EnableVersionQuery Property uint32 EnableVersionQuery {get;set;}
EnableWinsR Property bool EnableWinsR {get;set;}
ForestDirectoryPartitionBaseName Property string ForestDirectoryPartitionBaseName {get;}
ForwardDelegations Property bool ForwardDelegations {get;set;}
IgnoreServerLevelPolicies Property bool IgnoreServerLevelPolicies {get;set;}
IsReadOnlyDC Property bool IsReadOnlyDC {get;}
LameDelegationTtl Property CimInstance#DateTime LameDelegationTtl {get;set;}
ListeningIPAddress Property string[] ListeningIPAddress {get;set;}
LocalNetPriority Property bool LocalNetPriority {get;set;}
LocalNetPriorityMask Property uint32 LocalNetPriorityMask {get;set;}
LooseWildcarding Property bool LooseWildcarding {get;set;}
MajorVersion Property uint32 MajorVersion {get;}
MaximumRodcRsoAttemptsPerCycle Property uint32 MaximumRodcRsoAttemptsPerCycle {get;set;}
MaximumRodcRsoQueueLength Property uint32 MaximumRodcRsoQueueLength {get;set;}
MaximumTrustAnchorActiveRefreshInterval Property CimInstance#DateTime MaximumTrustAnchorActiveRefreshInterval {get...
MaxResourceRecordsInNonSecureUpdate Property uint32 MaxResourceRecordsInNonSecureUpdate {get;set;}
MinorVersion Property uint32 MinorVersion {get;}
NameCheckFlag Property uint32 NameCheckFlag {get;set;}
NoUpdateDelegations Property bool NoUpdateDelegations {get;set;}
OpenAclOnProxyUpdates Property bool OpenAclOnProxyUpdates {get;set;}
PSComputerName Property string PSComputerName {get;}
PublishAutoNet Property bool PublishAutoNet {get;set;}
QuietRecvFaultInterval Property uint32 QuietRecvFaultInterval {get;set;}
ReloadException Property bool ReloadException {get;set;}
RemoteIPv4RankBoost Property uint32 RemoteIPv4RankBoost {get;set;}
RemoteIPv6RankBoost Property uint32 RemoteIPv6RankBoost {get;set;}
RootTrustAnchorsURL Property string RootTrustAnchorsURL {get;set;}
RoundRobin Property bool RoundRobin {get;set;}
RpcProtocol Property uint32 RpcProtocol {get;set;}
ScopeOptionValue Property uint32 ScopeOptionValue {get;set;}
SelfTest Property uint32 SelfTest {get;set;}
SendPort Property uint32 SendPort {get;set;}
ServerLevelPluginDll Property string ServerLevelPluginDll {get;set;}
SilentlyIgnoreCNameUpdateConflicts Property bool SilentlyIgnoreCNameUpdateConflicts {get;set;}
SocketPoolExcludedPortRanges Property string[] SocketPoolExcludedPortRanges {get;set;}
SocketPoolSize Property uint32 SocketPoolSize {get;set;}
StrictFileParsing Property bool StrictFileParsing {get;set;}
SyncDsZoneSerial Property uint32 SyncDsZoneSerial {get;set;}
TcpReceivePacketSize Property uint32 TcpReceivePacketSize {get;set;}
UpdateOptions Property uint32 UpdateOptions {get;set;}
VirtualizationInstanceOptionValue Property uint32 VirtualizationInstanceOptionValue {get;set;}
WriteAuthorityNs Property bool WriteAuthorityNs {get;set;}
XfrConnectTimeout Property uint32 XfrConnectTimeout {get;set;}
XfrThrottleMultiplier Property uint32 XfrThrottleMultiplier {get;set;}
ZoneWritebackInterval Property CimInstance#DateTime ZoneWritebackInterval {get;set;}