diff --git a/CHANGELOG.md b/CHANGELOG.md index e24d634a..be82713e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed issue with CMAccounts with Get returning a string when only one account exists. - Fixed issue with Boundary groups containing VPN type boundaries. +### Changed + +- Added support for VPN and IPv6Prefix boundaries to the CMBoundaries resource. + ## [1.0.2] - 2021-05-12 ### Added diff --git a/README.md b/README.md index 95b51f3e..4b769446 100644 --- a/README.md +++ b/README.md @@ -455,7 +455,7 @@ you are using apply and auto correct. - **[String] Value** _(Key)_: Specifies the value for the boundary. - **[String] DisplayName** _(Required)_: Specifies the display name of the boundary. - **[String] Type** _(Required)_: Specifies the type of boundary. - - Values include: { ADSite | IPSubnet | IPRange + - Values include: { ADSite | IPSubnet | IPRange | VPN | IPv6Prefix } - **[String] Ensure** _(Write)_: Specifies whether the boundary is present or absent. - Values include: { Present | Absent } diff --git a/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.psm1 b/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.psm1 index 8f7786b3..ed54e1ba 100644 --- a/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.psm1 +++ b/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.psm1 @@ -18,7 +18,7 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' Not used in Get-TargetResource. .Parameter Type - Specifies the type of boundary ADSite, IPSubnet, or IPRange. + Specifies the type of boundary ADSite, IPSubnet, IPRange, VPN, or IPv6Prefix. .Parameter Value Specifies the value for the boundary. @@ -38,7 +38,7 @@ function Get-TargetResource $DisplayName, [Parameter(Mandatory = $true)] - [ValidateSet('ADSite','IPSubnet','IPRange')] + [ValidateSet('ADSite','IPSubnet','IPRange','VPN','IPv6Prefix')] [String] $Type, @@ -53,9 +53,11 @@ function Get-TargetResource $convertBoundary = switch ($Type) { - 'IPSubnet' { '0' } - 'AdSite' { '1' } - 'IPRange' { '3' } + 'IPSubnet' { '0' } + 'AdSite' { '1' } + 'IPv6Prefix' { '2' } + 'IPRange' { '3' } + 'Vpn' { '4' } } if ($Type -eq 'IPSubnet') @@ -102,7 +104,7 @@ function Get-TargetResource Specifies the display name of the boundary. .Parameter Type - Specifies the type of boundary ADSite, IPSubnet, or IPRange. + Specifies the type of boundary ADSite, IPSubnet, IPRange, VPN, or IPv6Prefix. .Parameter Value Specifies the value for the boundary. @@ -124,7 +126,7 @@ function Set-TargetResource $DisplayName, [Parameter(Mandatory = $true)] - [ValidateSet('ADSite','IPSubnet','IPRange')] + [ValidateSet('ADSite','IPSubnet','IPRange','VPN','IPv6Prefix')] [String] $Type, @@ -187,7 +189,7 @@ function Set-TargetResource Specifies the display name of the boundary. .Parameter Type - Specifies the type of boundary ADSite, IPSubnet, or IPRange. + Specifies the type of boundary ADSite, IPSubnet, IPRange, VPN, or IPv6Prefix. .Parameter Value Specifies the value for the boundary. @@ -210,7 +212,7 @@ function Test-TargetResource $DisplayName, [Parameter(Mandatory = $true)] - [ValidateSet('ADSite','IPSubnet','IPRange')] + [ValidateSet('ADSite','IPSubnet','IPRange','VPN','IPv6Prefix')] [String] $Type, diff --git a/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.schema.mof b/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.schema.mof index 4f64c2ff..99fedb1c 100644 --- a/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.schema.mof +++ b/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.schema.mof @@ -3,7 +3,7 @@ class DSC_CMBoundaries : OMI_BaseResource { [Key, Description("Specifies the SiteCode for the Configuration Manager site.")] String SiteCode; [Key, Description("Specifies the value for the boundary.")] String Value; - [Key, Description("Specifies the type of boundary"), ValueMap {"ADSite","IPSubnet","IPRange"}, Values {"ADSite","IPSubnet","IPRange"}] String Type; + [Key, Description("Specifies the type of boundary"), ValueMap {"ADSite","IPSubnet","IPRange","VPN","IPv6Prefix"}, Values {"ADSite","IPSubnet","IPRange","VPN","IPv6Prefix"}] String Type; [Required, Description("Specifies the display name of the boundary")] String DisplayName; [Write, Description("Specifies whether the boundary is present or absent."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Read, Description("Specifies the SiteCode for the Configuration Manager site.")] String BoundaryID; diff --git a/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 b/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 index 9323738d..eedd9e29 100644 --- a/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 +++ b/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 @@ -34,5 +34,41 @@ Configuration Example Value = '10.1.1.1-10.1.1.255' Ensure = 'Present' } + + CMBoundaries ExampleVpn + { + SiteCode = 'Lab' + DisplayName = 'VPN AutoDetect' + Type = 'VPN' + Value = 'Auto:On' + Ensure = 'Present' + } + + CMBoundaries ExampleVpnDescription + { + SiteCode = 'Lab' + DisplayName = 'VPN ConnectionDescription' + Type = 'VPN' + Value = 'Description:Contoso VPN' + Ensure = 'Present' + } + + CMBoundaries ExampleVpnName + { + SiteCode = 'Lab' + DisplayName = 'VPN ConnectionName' + Type = 'VPN' + Value = 'Name:Contoso.com' + Ensure = 'Present' + } + + CMBoundaries ExampleIPv6 + { + SiteCode = 'Lab' + DisplayName = 'IPv6 1' + Type = 'IPv6Prefix' + Value = '2001:0DB8:0000:000b' + Ensure = 'Present' + } } } diff --git a/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 b/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 index f5fce64f..5931afa9 100644 --- a/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 +++ b/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 @@ -229,8 +229,9 @@ function ConvertTo-CimBoundaries { '0' { 'IPSubnet' } '1' { 'AdSite' } + '2' { 'IPv6Prefix' } '3' { 'IPRange' } - '4' { 'VPN' } + '4' { 'Vpn' } } $cimProperties = @{ diff --git a/source/Modules/ConfigMgrCBDsc.ReverseDsc/ConfigMgrCBDsc.ReverseDsc.psm1 b/source/Modules/ConfigMgrCBDsc.ReverseDsc/ConfigMgrCBDsc.ReverseDsc.psm1 index 20e47d92..aab1cd7a 100644 --- a/source/Modules/ConfigMgrCBDsc.ReverseDsc/ConfigMgrCBDsc.ReverseDsc.psm1 +++ b/source/Modules/ConfigMgrCBDsc.ReverseDsc/ConfigMgrCBDsc.ReverseDsc.psm1 @@ -989,7 +989,6 @@ Configuration ConfigureSccm DiscoverDistributionGroupMembership = `$CMGroupDiscovery.DiscoverDistributionGroupMembership Start = `$CMGroupDiscovery.Start ScheduleType = `$CMGroupDiscovery.ScheduleType - RefreshType = `$CMGroupDiscovery.RefreshType RecurInterval = `$CMGroupDiscovery.RecurInterval DayOfWeek = `$CMGroupDiscovery.DayOfWeek } @@ -1083,7 +1082,6 @@ Configuration ConfigureSccm DiscoverDistributionGroupMembership = `$CMGroupDiscovery.DiscoverDistributionGroupMembership Start = `$CMGroupDiscovery.Start ScheduleType = `$CMGroupDiscovery.ScheduleType - RefreshType = `$CMGroupDiscovery.RefreshType RecurInterval = `$CMGroupDiscovery.RecurInterval DayOfWeek = `$CMGroupDiscovery.DayOfWeek } @@ -1175,7 +1173,6 @@ Configuration ConfigureSccm DiscoverDistributionGroupMembership = `$CMGroupDiscovery.DiscoverDistributionGroupMembership Start = `$CMGroupDiscovery.Start ScheduleType = `$CMGroupDiscovery.ScheduleType - RefreshType = `$CMGroupDiscovery.RefreshType RecurInterval = `$CMGroupDiscovery.RecurInterval DayOfWeek = `$CMGroupDiscovery.DayOfWeek } @@ -1277,7 +1274,6 @@ Configuration ConfigureSccm DiscoverDistributionGroupMembership = `$CMGroupDiscovery.DiscoverDistributionGroupMembership Start = `$CMGroupDiscovery.Start ScheduleType = `$CMGroupDiscovery.ScheduleType - RefreshType = `$CMGroupDiscovery.RefreshType RecurInterval = `$CMGroupDiscovery.RecurInterval DayOfWeek = `$CMGroupDiscovery.DayOfWeek } @@ -1376,7 +1372,6 @@ Configuration ConfigureSccm DiscoverDistributionGroupMembership = `$CMGroupDiscovery.DiscoverDistributionGroupMembership Start = `$CMGroupDiscovery.Start ScheduleType = `$CMGroupDiscovery.ScheduleType - RefreshType = `$CMGroupDiscovery.RefreshType RecurInterval = `$CMGroupDiscovery.RecurInterval DayOfWeek = `$CMGroupDiscovery.DayOfWeek } @@ -1473,7 +1468,6 @@ Configuration ConfigureSccm DiscoverDistributionGroupMembership = `$CMGroupDiscovery.DiscoverDistributionGroupMembership Start = `$CMGroupDiscovery.Start ScheduleType = `$CMGroupDiscovery.ScheduleType - RefreshType = `$CMGroupDiscovery.RefreshType RecurInterval = `$CMGroupDiscovery.RecurInterval DayOfWeek = `$CMGroupDiscovery.DayOfWeek } diff --git a/tests/Unit/CMBoundaries.tests.ps1 b/tests/Unit/CMBoundaries.tests.ps1 index 187e2e88..540f5547 100644 --- a/tests/Unit/CMBoundaries.tests.ps1 +++ b/tests/Unit/CMBoundaries.tests.ps1 @@ -76,6 +76,38 @@ try Ensure = 'Absent' } + $inputVpnPresent = @{ + SiteCode = 'Lab' + DisplayName = 'VPN 1' + Type = 'VPN' + Value = 'Auto:On' + } + + $inputIPv6Present = @{ + SiteCode = 'Lab' + DisplayName = 'IPv6 1' + Type = 'IPv6Prefix' + Value = '2001:0DB8:0000:000b' + } + + $boundaryVpnReturn = @( + @{ + BoundaryId = 1677726 + BoundaryType = 4 + DisplayName = 'VPN 1' + Value = 'Auto:On' + } + ) + + $boundaryIPv6Return = @( + @{ + BoundaryId = 1677726 + BoundaryType = 2 + DisplayName = 'IPv6 1' + Value = '2001:0DB8:0000:000b' + } + ) + $boundarySubnetReturn = @( @{ BoundaryId = 1677726 @@ -191,6 +223,32 @@ try $result.BoundaryId | Should -Be -ExpectedValue '1677726' } + It 'Should return desired result for Vpn return' { + Mock -CommandName Get-CMBoundary -MockWith { $boundaryVpnReturn } + + $result = Get-TargetResource @inputVpnPresent + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.DisplayName | Should -Be -ExpectedValue 'VPN 1' + $result.Value | Should -Be -ExpectedValue 'Auto:On' + $result.Type | Should -Be -ExpectedValue 'VPN' + $result.Ensure | Should -Be -ExpectedValue 'Present' + $result.BoundaryId | Should -Be -ExpectedValue '1677726' + } + + It 'Should return desired result for IPv6 return' { + Mock -CommandName Get-CMBoundary -MockWith { $boundaryIPv6Return } + + $result = Get-TargetResource @inputIPv6Present + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.DisplayName | Should -Be -ExpectedValue 'IPv6 1' + $result.Value | Should -Be -ExpectedValue '2001:0DB8:0000:000b' + $result.Type | Should -Be -ExpectedValue 'IPv6Prefix' + $result.Ensure | Should -Be -ExpectedValue 'Present' + $result.BoundaryId | Should -Be -ExpectedValue '1677726' + } + It 'Should return desired result when boundary not found' { Mock -CommandName Get-CMBoundary -MockWith { $null } diff --git a/tests/Unit/ConfigMgrCBDsc.ResourceHelper.tests.ps1 b/tests/Unit/ConfigMgrCBDsc.ResourceHelper.tests.ps1 index 5eec19b9..cdd1a53d 100644 --- a/tests/Unit/ConfigMgrCBDsc.ResourceHelper.tests.ps1 +++ b/tests/Unit/ConfigMgrCBDsc.ResourceHelper.tests.ps1 @@ -229,6 +229,11 @@ InModuleScope $script:subModuleName { BoundaryType = 4 Value = 'Description:Virtual Adapter' } + @{ + BoundaryID = 16777235 + BoundaryType = 2 + Value = '2001:0DB8:0000:000b' + } ) } @@ -238,7 +243,7 @@ InModuleScope $script:subModuleName { $result = ConvertTo-CimBoundaries -InputObject $inputObject $result | Should -BeOfType '[Microsoft.Management.Infrastructure.CimInstance]' - $result.Count | Should -Be -ExpectedValue 4 + $result.Count | Should -Be -ExpectedValue 5 $result[0].Value | Should -Be -ExpectedValue '10.1.1.1-10.1.1.255' $result[0].Type | Should -Be -ExpectedValue 'IPRange' $result[1].Value | Should -Be -ExpectedValue '10.1.2.0' @@ -247,6 +252,8 @@ InModuleScope $script:subModuleName { $result[2].Type | Should -Be -ExpectedValue 'ADSite' $result[3].Value | Should -Be -ExpectedValue 'Description:Virtual Adapter' $result[3].Type | Should -Be -ExpectedValue 'VPN' + $result[4].Value | Should -Be -ExpectedValue '2001:0DB8:0000:000b' + $result[4].Type | Should -Be -ExpectedValue 'IPv6Prefix' } } }