diff --git a/CHANGELOG.md b/CHANGELOG.md index cc80d48..6c74411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - RenameNetworkAdapters - Add composite to rename network adapters - Add documentation +- DnsSuffixes + - new resource to configure connection-specific DNS suffixes ### Changed diff --git a/source/DSCResources/DnsSuffixes/DnsSuffixes.psd1 b/source/DSCResources/DnsSuffixes/DnsSuffixes.psd1 new file mode 100644 index 0000000..dc54ef3 --- /dev/null +++ b/source/DSCResources/DnsSuffixes/DnsSuffixes.psd1 @@ -0,0 +1,15 @@ +@{ + RootModule = 'DnsSuffixes.schema.psm1' + + ModuleVersion = '0.0.1' + + GUID = '20392fe9-270d-4295-af2c-2401dd015596' + + Author = 'NA' + + CompanyName = 'NA' + + Copyright = 'NA' + + DscResourcesToExport = @('DnsSuffixes') +} diff --git a/source/DSCResources/DnsSuffixes/DnsSuffixes.schema.psm1 b/source/DSCResources/DnsSuffixes/DnsSuffixes.schema.psm1 new file mode 100644 index 0000000..4ec2267 --- /dev/null +++ b/source/DSCResources/DnsSuffixes/DnsSuffixes.schema.psm1 @@ -0,0 +1,26 @@ +configuration DnsSuffixes +{ + param + ( + [Parameter(Mandatory = $true)] + [hashtable[]] + $Suffixes + ) + + Import-DscResource -ModuleName NetworkingDsc -Name DnsConnectionSuffix + + foreach ($suffix in $Suffixes) + { + # Remove Case Sensitivity of ordered Dictionary or Hashtables + $suffix = @{} + $suffix + + if (-not $suffix.ContainsKey('Ensure')) + { + $suffix.Ensure = 'Present' + } + + $executionName = "dnssuffix_$($suffix.InterfaceAlias)_$($suffix.ConnectionSpecificSuffix)" -replace '[()-.:\s]', '_' + + (Get-DscSplattedResource -ResourceName DnsConnectionSuffix -ExecutionName $executionName -Properties $suffix -NoInvoke).Invoke($suffix) + } +} diff --git a/tests/Unit/DSCResources/Assets/Config/DnsSuffixes.yml b/tests/Unit/DSCResources/Assets/Config/DnsSuffixes.yml new file mode 100644 index 0000000..4aead39 --- /dev/null +++ b/tests/Unit/DSCResources/Assets/Config/DnsSuffixes.yml @@ -0,0 +1,3 @@ +Suffixes: + - InterfaceAlias: en0 + ConnectionSpecificSuffix: contoso.com