From f12e0953d67afefa803a70a8d519ee090a8664bf Mon Sep 17 00:00:00 2001 From: Nick Ellis Date: Tue, 21 Sep 2021 12:31:24 -0400 Subject: [PATCH 1/4] Adding support for new boundary types --- CHANGELOG.md | 4 ++ README.md | 2 +- .../DSC_CMBoundaries/DSC_CMBoundaries.psm1 | 20 ++++--- .../DSC_CMBoundaries.schema.mof | 2 +- .../CMBoundaries/CMBoundaries_Present.ps1 | 37 ++++++++++++ .../ConfigMgrCBDsc.ResourceHelper.psm1 | 1 + tests/Unit/CMBoundaries.tests.ps1 | 58 +++++++++++++++++++ .../ConfigMgrCBDsc.ResourceHelper.tests.ps1 | 9 ++- 8 files changed, 121 insertions(+), 12 deletions(-) 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..0c0d5b9d 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..31e73227 100644 --- a/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 +++ b/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 @@ -34,5 +34,42 @@ 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..b4db771c 100644 --- a/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 +++ b/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 @@ -229,6 +229,7 @@ function ConvertTo-CimBoundaries { '0' { 'IPSubnet' } '1' { 'AdSite' } + '2' { 'IPv6Prefix' } '3' { 'IPRange' } '4' { 'VPN' } } diff --git a/tests/Unit/CMBoundaries.tests.ps1 b/tests/Unit/CMBoundaries.tests.ps1 index 187e2e88..18301181 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' } } } From d7ae68e32f037e67864507d543aa89d33abcfcf8 Mon Sep 17 00:00:00 2001 From: Nick Ellis Date: Tue, 21 Sep 2021 13:40:43 -0400 Subject: [PATCH 2/4] Resolving capitalization --- .../DSC_CMBoundaries/DSC_CMBoundaries.psm1 | 2 +- .../Resources/CMBoundaries/CMBoundaries_Present.ps1 | 6 +++--- .../ConfigMgrCBDsc.ResourceHelper.psm1 | 2 +- tests/Unit/CMBoundaries.tests.ps1 | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.psm1 b/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.psm1 index 0c0d5b9d..ed54e1ba 100644 --- a/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.psm1 +++ b/source/DSCResources/DSC_CMBoundaries/DSC_CMBoundaries.psm1 @@ -57,7 +57,7 @@ function Get-TargetResource 'AdSite' { '1' } 'IPv6Prefix' { '2' } 'IPRange' { '3' } - 'VPN' { '4' } + 'Vpn' { '4' } } if ($Type -eq 'IPSubnet') diff --git a/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 b/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 index 31e73227..e2179390 100644 --- a/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 +++ b/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 @@ -35,7 +35,7 @@ Configuration Example Ensure = 'Present' } - CMBoundaries ExampleVPN + CMBoundaries ExampleVpn { SiteCode = 'Lab' DisplayName = 'VPN AutoDetect' @@ -45,7 +45,7 @@ Configuration Example } - CMBoundaries ExampleVPNDescription + CMBoundaries ExampleVpnDescription { SiteCode = 'Lab' DisplayName = 'VPN ConnectionDescription' @@ -54,7 +54,7 @@ Configuration Example Ensure = 'Present' } - CMBoundaries ExampleVPNName + CMBoundaries ExampleVpnName { SiteCode = 'Lab' DisplayName = 'VPN ConnectionName' diff --git a/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 b/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 index b4db771c..5931afa9 100644 --- a/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 +++ b/source/Modules/ConfigMgrCBDsc.ResourceHelper/ConfigMgrCBDsc.ResourceHelper.psm1 @@ -231,7 +231,7 @@ function ConvertTo-CimBoundaries '1' { 'AdSite' } '2' { 'IPv6Prefix' } '3' { 'IPRange' } - '4' { 'VPN' } + '4' { 'Vpn' } } $cimProperties = @{ diff --git a/tests/Unit/CMBoundaries.tests.ps1 b/tests/Unit/CMBoundaries.tests.ps1 index 18301181..540f5547 100644 --- a/tests/Unit/CMBoundaries.tests.ps1 +++ b/tests/Unit/CMBoundaries.tests.ps1 @@ -76,7 +76,7 @@ try Ensure = 'Absent' } - $inputVPNPresent = @{ + $inputVpnPresent = @{ SiteCode = 'Lab' DisplayName = 'VPN 1' Type = 'VPN' @@ -90,7 +90,7 @@ try Value = '2001:0DB8:0000:000b' } - $boundaryVPNReturn = @( + $boundaryVpnReturn = @( @{ BoundaryId = 1677726 BoundaryType = 4 @@ -223,10 +223,10 @@ try $result.BoundaryId | Should -Be -ExpectedValue '1677726' } - It 'Should return desired result for VPN return' { - Mock -CommandName Get-CMBoundary -MockWith { $boundaryVPNReturn } + It 'Should return desired result for Vpn return' { + Mock -CommandName Get-CMBoundary -MockWith { $boundaryVpnReturn } - $result = Get-TargetResource @inputVPNPresent + $result = Get-TargetResource @inputVpnPresent $result | Should -BeOfType System.Collections.HashTable $result.SiteCode | Should -Be -ExpectedValue 'Lab' $result.DisplayName | Should -Be -ExpectedValue 'VPN 1' From a3627151df6b5d07663f3583339f8805481e03c9 Mon Sep 17 00:00:00 2001 From: Nick Ellis Date: Fri, 24 Sep 2021 08:04:11 -0400 Subject: [PATCH 3/4] Fixing final PR comments --- .../ConfigMgrCBDsc.ReverseDsc.psm1 | 6 ------ 1 file changed, 6 deletions(-) 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 } From 3160b2afc25caf6f85af2ccf1b72ef494cdf61e9 Mon Sep 17 00:00:00 2001 From: Nick Ellis Date: Fri, 24 Sep 2021 10:04:12 -0400 Subject: [PATCH 4/4] Resolving PR Comments --- source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 b/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 index e2179390..eedd9e29 100644 --- a/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 +++ b/source/Examples/Resources/CMBoundaries/CMBoundaries_Present.ps1 @@ -44,7 +44,6 @@ Configuration Example Ensure = 'Present' } - CMBoundaries ExampleVpnDescription { SiteCode = 'Lab'