-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from PowerShell/dev
Release of version 1.11.0.0 of xDnsServer
- Loading branch information
Showing
10 changed files
with
857 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
[ClassVersion("1.0.0.0"), FriendlyName("xDnsRecord")] | ||
class MSFT_xDnsRecord : OMI_BaseResource | ||
{ | ||
[Key] string Name; | ||
[Key] string Zone; | ||
[Required, ValueMap{"ARecord","CName"}, Values{"ARecord","CName"}] string Type; | ||
[Key] string Target; | ||
[Write] string DnsServer; | ||
[Key, Description("Specifies the name of the DNS server resource record object.")] string Name; | ||
[Key, Description("Specifies the name of a DNS zone.")] string Zone; | ||
[Required, Description("Specifies the type of DNS record."), ValueMap{"ARecord","CName","Ptr"}, Values{"ARecord","CName","Ptr"}] string Type; | ||
[Key, Description("Specifies the Target Hostname or IP Address.")] string Target; | ||
[Write, Description("Name of the DnsServer to create the record on.")] string DnsServer; | ||
[Write, Description("Should this DNS resource record be present or absent"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
189 changes: 189 additions & 0 deletions
189
DSCResources/MSFT_xDnsServerZoneAging/MSFT_xDnsServerZoneAging.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
|
||
<# | ||
.SYNOPSIS | ||
Get the DNS zone aging settings. | ||
.PARAMETER Name | ||
Name of the DNS forward or reverse loookup zone. | ||
.PARAMETER Enabled | ||
Option to enable scavenge stale resource records on the zone. | ||
#> | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$Name, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.Boolean] | ||
$Enabled | ||
) | ||
|
||
Write-Verbose -Message "Getting the DNS zone aging for $Name." | ||
|
||
# Get the current zone aging from the local DNS server | ||
$zoneAging = Get-DnsServerZoneAging -Name $Name | ||
|
||
return @{ | ||
Name = $Name | ||
Enabled = $zoneAging.AgingEnabled | ||
RefreshInterval = $zoneAging.RefreshInterval.TotalHours | ||
NoRefreshInterval = $zoneAging.NoRefreshInterval.TotalHours | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Set the DNS zone aging settings. | ||
.PARAMETER Name | ||
Name of the DNS forward or reverse loookup zone. | ||
.PARAMETER Enabled | ||
Option to enable scavenge stale resource records on the zone. | ||
.PARAMETER RefreshInterval | ||
Refresh interval for record scavencing in hours. Default value is 7 days. | ||
.PARAMETER NoRefreshInterval | ||
No-refresh interval for record scavencing in hours. Default value is 7 days. | ||
#> | ||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$Name, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.Boolean] | ||
$Enabled, | ||
|
||
[Parameter()] | ||
[System.UInt32] | ||
$RefreshInterval = 168, | ||
|
||
[Parameter()] | ||
[System.UInt32] | ||
$NoRefreshInterval = 168 | ||
) | ||
|
||
$currentConfiguration = Get-TargetResource -Name $Name -Enabled $Enabled | ||
|
||
# Enable or disable zone aging | ||
if ($currentConfiguration.Enabled -ne $Enabled) | ||
{ | ||
if ($Enabled) | ||
{ | ||
Write-Verbose -Message "Enable DNS zone aging on $Name." | ||
} | ||
else | ||
{ | ||
Write-Verbose -Message "Disable DNS zone aging on $Name." | ||
} | ||
|
||
Set-DnsServerZoneAging -Name $Name -Aging $Enabled -WarningAction 'SilentlyContinue' | ||
} | ||
|
||
# Update the refresh interval | ||
if ($PSBoundParameters.ContainsKey('RefreshInterval')) | ||
{ | ||
if ($currentConfiguration.RefreshInterval -ne $RefreshInterval) | ||
{ | ||
Write-Verbose -Message "Set DNS zone refresh interval to $RefreshInterval hours." | ||
|
||
$refreshIntervalTimespan = [System.TimeSpan]::FromHours($RefreshInterval) | ||
|
||
<# | ||
Hide the following warning if aging is not enabled: Specified | ||
parameters related to aging of records have been set. However, | ||
aging was not enabled and hence the settings are ineffective. | ||
#> | ||
Set-DnsServerZoneAging -Name $Name -RefreshInterval $refreshIntervalTimespan -WarningAction 'SilentlyContinue' | ||
} | ||
} | ||
|
||
# Update the no refresh interval | ||
if ($PSBoundParameters.ContainsKey('NoRefreshInterval')) | ||
{ | ||
if ($currentConfiguration.NoRefreshInterval -ne $NoRefreshInterval) | ||
{ | ||
Write-Verbose -Message "Set DNS zone no refresh interval to $NoRefreshInterval hours." | ||
|
||
$noRefreshIntervalTimespan = [System.TimeSpan]::FromHours($NoRefreshInterval) | ||
|
||
<# | ||
Hide the following warning if aging is not enabled: Specified | ||
parameters related to aging of records have been set. However, | ||
aging was not enabled and hence the settings are ineffective. | ||
#> | ||
Set-DnsServerZoneAging -Name $Name -NoRefreshInterval $noRefreshIntervalTimespan -WarningAction 'SilentlyContinue' | ||
} | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Test the DNS zone aging settings. | ||
.PARAMETER Name | ||
Name of the DNS forward or reverse loookup zone. | ||
.PARAMETER Enabled | ||
Option to enable scavenge stale resource records on the zone. | ||
.PARAMETER RefreshInterval | ||
Refresh interval for record scavencing in hours. Default value is 7 days. | ||
.PARAMETER NoRefreshInterval | ||
No-refresh interval for record scavencing in hours. Default value is 7 days. | ||
#> | ||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Boolean])] | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$Name, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.Boolean] | ||
$Enabled, | ||
|
||
[Parameter()] | ||
[System.UInt32] | ||
$RefreshInterval = 168, | ||
|
||
[Parameter()] | ||
[System.UInt32] | ||
$NoRefreshInterval = 168 | ||
) | ||
|
||
Write-Verbose -Message "Testing the DNS zone aging for $Name." | ||
|
||
$currentConfiguration = Get-TargetResource -Name $Name -Enabled $Enabled | ||
|
||
$isDesiredState = $currentConfiguration.Enabled -eq $Enabled | ||
|
||
if ($PSBoundParameters.ContainsKey('RefreshInterval')) | ||
{ | ||
$isDesiredState = $isDesiredState -and $currentConfiguration.RefreshInterval -eq $RefreshInterval | ||
} | ||
|
||
if ($PSBoundParameters.ContainsKey('NoRefreshInterval')) | ||
{ | ||
$isDesiredState = $isDesiredState -and $currentConfiguration.NoRefreshInterval -eq $NoRefreshInterval | ||
} | ||
|
||
return $isDesiredState | ||
} |
8 changes: 8 additions & 0 deletions
8
DSCResources/MSFT_xDnsServerZoneAging/MSFT_xDnsServerZoneAging.schema.mof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ClassVersion("1.0.0.0"), FriendlyName("xDnsServerZoneAging")] | ||
class MSFT_xDnsServerZoneAging : OMI_BaseResource | ||
{ | ||
[Key, Description("Name of the DNS forward or reverse loookup zone.")] String Name; | ||
[Required, Description("Option to enable scavenge stale resource records on the zone.")] Boolean Enabled; | ||
[Write, Description("Refresh interval for record scavencing in hours. Default value is 7 days.")] UInt32 RefreshInterval; | ||
[Write, Description("No-refresh interval for record scavencing in hours. Default value is 7 days.")] UInt32 NoRefreshInterval; | ||
}; |
Oops, something went wrong.