Skip to content

Commit

Permalink
Add DNS suffixes resource (#217)
Browse files Browse the repository at this point in the history
* Add DNS suffixes resource

* Add missing parameter attribtue
  • Loading branch information
nyanhp authored Nov 22, 2023
1 parent a6d8b9f commit e57ad97
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions source/DSCResources/DnsSuffixes/DnsSuffixes.psd1
Original file line number Diff line number Diff line change
@@ -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')
}
26 changes: 26 additions & 0 deletions source/DSCResources/DnsSuffixes/DnsSuffixes.schema.psm1
Original file line number Diff line number Diff line change
@@ -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)
}
}
3 changes: 3 additions & 0 deletions tests/Unit/DSCResources/Assets/Config/DnsSuffixes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Suffixes:
- InterfaceAlias: en0
ConnectionSpecificSuffix: contoso.com

0 comments on commit e57ad97

Please sign in to comment.