From 33498209ff5ee54e8384cd2d60e20f2f00f6b9d0 Mon Sep 17 00:00:00 2001 From: Nick Ellis Date: Tue, 16 Mar 2021 13:00:41 -0400 Subject: [PATCH 1/6] Initial Commit --- CHANGELOG.md | 1 + README.md | 19 +- .../DSC_CMAssetIntelligencePoint.psm1 | 232 ++++++++++-------- .../DSC_CMAssetIntelligencePoint.schema.mof | 14 +- .../DSC_CMAssetIntelligencePoint.strings.psd1 | 5 - .../CMAssetIntelligencePoint_Present.ps1 | 7 +- 6 files changed, 155 insertions(+), 123 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 202fe3d4..f740ad6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added additional schedule types for CMCollections schedules. - Updated CMSystemDiscovery to warn when exceeding max allowed hours or days or minutes and when specifying under the minimum allowed minutes. +- Updated CMAssetIntelligencePoint to use the helper functions for scheduling. ### Removed diff --git a/README.md b/README.md index cdbd6f0c..89821713 100644 --- a/README.md +++ b/README.md @@ -589,8 +589,23 @@ you are using apply and auto correct. Online authentication certificate (.pfx) file. If used, this must be in UNC format. Local paths are not allowed. Mutually exclusive with the RemoveCertificate parameter. -- **[EmbeddedInstance] Schedule** _(Write)_: Specifies when the asset - intelligence catalog is synchronized. (RecurInterval, RecurCount) +- **[String] Start** _(Write)_: Specifies the start date and start time for the + synchronization schedule Month/Day/Year, example 1/1/2020 02:00. +- **[String] ScheduleType** _(Write)_: Specifies the schedule type for the synchronization + schedule. + - Values include: { MonthlyByDay | MonthlyByWeek | Weekly | Days | None } +- **[UInt32] RecurInterval** _(Write)_: Specifies how often the ScheduleType is run. + - Values Range: 0 - 31 +- **[String] MonthlyWeekOrder** _(Write)_: Specifies week order for MonthlyByWeek + schedule type. + - Values include: { First | Second | Third | Fourth | Last } +- **[String] DayOfWeek** _(Write)_: Specifies the day of week name for MonthlyByWeek + and Weekly schedules. + - Values include: { Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | + Saturday } +- **[UInt32] DayOfMonth** _(Write)_: Specifies the day number for MonthlyByDay schedules. + Note specifying 0 sets the schedule to run the last day of the month. + - Values Range: 0 - 31 - **[Boolean] Enable** _(Write)_: Specifies whether the installed asset intelligence role is enabled or disabled. - **[Boolean] EnableSynchronization** _(Write)_: Specifies whether to diff --git a/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 b/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 index 65b7ed1f..73eaf05d 100644 --- a/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 +++ b/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 @@ -51,11 +51,8 @@ function Get-TargetResource $syncSchedule = $apProps.PeriodicCatalogUpdateSchedule $status = 'Present' - $convertCimParam = @{ - ScheduleString = $syncSchedule - CimClassName = 'DSC_CMAssetIntelligenceSynchronizationSchedule' - } - $sSchedule = ConvertTo-CimCMScheduleString @convertCimParam + $sSchedule = Convert-CMSchedule -InputObject $syncSchedule + $schedule = Get-CMSchedule -ScheduleString $sSchedule } else { @@ -69,7 +66,12 @@ function Get-TargetResource CertificateFile = $cert Enable = $apEnabled EnableSynchronization = $syncEnabled - Schedule = $sSchedule + Start = $schedule.Start + ScheduleType = $schedule.ScheduleType + DayOfWeek = $schedule.DayofWeek + MonthlyWeekOrder = $schedule.WeekOrder + DayofMonth = $schedule.MonthDay + RecurInterval = $schedule.RecurInterval Ensure = $status } } @@ -93,8 +95,24 @@ function Get-TargetResource If used, this must be in UNC format. Local paths are not allowed. Mutually exclusive with the CertificateFile Parameter. - .PARAMETER Schedule - Specifies when the asset intelligence catalog is synchronized. + .PARAMETER Start + Specifies the start date and start time for the synchronization schedule Month/Day/Year, example 1/1/2020 02:00. + + .PARAMETER ScheduleType + Specifies the schedule type for the synchronization schedule. + + .PARAMETER RecurInterval + Specifies how often the ScheduleType is run. + + .PARAMETER MonthlyByWeek + Specifies week order for MonthlyByWeek schedule type. + + .PARAMETER DayOfWeek + Specifies the day of week name for MonthlyByWeek and Weekly schedules. + + .PARAMETER DayOfMonth + Specifies the day number for MonthlyByDay schedules. + Note specifying 0 sets the schedule to run the last day of the month. .PARAMETER Enable Specifies whether the installed asset intelligence role is enabled or disabled. @@ -135,8 +153,33 @@ function Set-TargetResource $CertificateFile, [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance] - $Schedule, + [String] + $Start, + + [Parameter()] + [ValidateSet('MonthlyByDay','MonthlyByWeek','Weekly','Days','None')] + [String] + $ScheduleType, + + [Parameter()] + [ValidateRange(1,31)] + [UInt32] + $RecurInterval, + + [Parameter()] + [ValidateSet('First','Second','Third','Fourth','Last')] + [String] + $MonthlyWeekOrder, + + [Parameter()] + [ValidateSet('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')] + [String] + $DayOfWeek, + + [Parameter()] + [ValidateRange(0,31)] + [UInt32] + $DayOfMonth, [Parameter()] [Boolean] @@ -162,7 +205,7 @@ function Set-TargetResource try { - if (($Schedule) -and ($EnableSynchronization -eq $false)) + if (($ScheduleType) -and ($EnableSynchronization -eq $false)) { throw $script:localizedData.ScheduleNoSync } @@ -215,66 +258,30 @@ function Set-TargetResource } } - if (-not [string]::IsNullOrEmpty($Schedule)) + if ($ScheduleType) { - if (($state.Ensure -eq 'Absent' -and $Schedule.RecurCount -eq 0) -or - ($Schedule.RecurCount -eq 0 -and $state.Schedule)) + $valuesToValidate = @('ScheduleType','RecurInterval','MonthlyWeekOrder','DayOfWeek','DayOfMonth','Start') + foreach ($item in $valuesToValidate) { - $setSchedule = $true - Write-Verbose -Message $script:localizedData.SetNoSchedule - } - elseif (-not ($state.Schedule) -and ($Schedule.RecurCount -ne 0)) - { - Write-Verbose -Message ($script:localizedData.SetSchedule ` - -f $Schedule.RecurInterval, $Schedule.RecurCount) - $setSchedule = $true - } - elseif (($state.Schedule) -and ($Schedule.RecurCount -ne 0)) - { - $newSchedule = @{ - RecurInterval = $Schedule.RecurInterval - RecurCount = $Schedule.RecurCount - } - - $desiredSchedule = New-CMSchedule @newSchedule - - $currentSchedule = @{ - RecurInterval = $state.Schedule.RecurInterval - RecurCount = $state.Schedule.RecurCount - } - - $stateSchedule = New-CMSchedule @currentSchedule - - $array = @('DayDuration','DaySpan','HourDuration','HourSpan','IsGMT') - - foreach ($item in $array) + if ($PSBoundParameters.ContainsKey($item)) { - if ($desiredSchedule.$($item) -ne $stateSchedule.$($item)) - { - Write-Verbose -Message ($script:localizedData.ScheduleItem ` - -f $item, $($desiredSchedule.$($item)), $($stateSchedule.$($item))) - $setSchedule = $true + $scheduleCheck += @{ + $item = $PSBoundParameters[$item] } } } - if ($setSchedule -eq $true) - { - if ($Schedule.RecurCount -eq 0) - { - $desiredSchedule = New-CMSchedule -Nonrecurring - } - elseif (-not ($state.Schedule)) - { - $desiredScheduleSet = @{ - RecurInterval = $Schedule.RecurInterval - RecurCount = $Schedule.RecurCount - } - $desiredSchedule = New-CMSchedule @desiredScheduleSet - } - $buildingParams += @{ - Schedule = $desiredSchedule - } + $schedResult = Test-CMSchedule @scheduleCheck -State $state + } + + if ($schedResult -eq $false) + { + $sched = Set-CMSchedule @scheduleCheck + $newSchedule = New-CMSchedule @sched + + Write-Verbose -Message $script:localizedData.NewSchedule + $buildingParams += @{ + Schedule = $newSchedule } } @@ -323,8 +330,24 @@ function Set-TargetResource If used, this must be in UNC format. Local paths are not allowed. Mutually exclusive with the CertificateFile Parameter. - .PARAMETER Schedule - Specifies when the asset intelligence catalog is synchronized. + .PARAMETER Start + Specifies the start date and start time for the synchronization schedule Month/Day/Year, example 1/1/2020 02:00. + + .PARAMETER ScheduleType + Specifies the schedule type for the synchronization schedule. + + .PARAMETER RecurInterval + Specifies how often the ScheduleType is run. + + .PARAMETER MonthlyByWeek + Specifies week order for MonthlyByWeek schedule type. + + .PARAMETER DayOfWeek + Specifies the day of week name for MonthlyByWeek and Weekly schedules. + + .PARAMETER DayOfMonth + Specifies the day number for MonthlyByDay schedules. + Note specifying 0 sets the schedule to run the last day of the month. .PARAMETER Enable Specifies whether the installed asset intelligence role is enabled or disabled. @@ -366,8 +389,33 @@ function Test-TargetResource $CertificateFile, [Parameter()] - [Microsoft.Management.Infrastructure.CimInstance] - $Schedule, + [String] + $Start, + + [Parameter()] + [ValidateSet('MonthlyByDay','MonthlyByWeek','Weekly','Days','None')] + [String] + $ScheduleType, + + [Parameter()] + [ValidateRange(1,31)] + [UInt32] + $RecurInterval, + + [Parameter()] + [ValidateSet('First','Second','Third','Fourth','Last')] + [String] + $MonthlyWeekOrder, + + [Parameter()] + [ValidateSet('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')] + [String] + $DayOfWeek, + + [Parameter()] + [ValidateRange(0,31)] + [UInt32] + $DayOfMonth, [Parameter()] [Boolean] @@ -423,47 +471,25 @@ function Test-TargetResource $result = $false } - if (-not [string]::IsNullOrEmpty($Schedule)) + if ($ScheduleType) { - if (($Schedule.RecurCount -eq 0) -and ($state.Schedule)) - { - $result = $false - Write-Verbose -Message $script:localizedData.NoSchedule - } - elseif (-not ($state.Schedule) -and ($Schedule.RecurCount -ne 0)) + $valuesToValidate = @('ScheduleType','RecurInterval','MonthlyWeekOrder','DayOfWeek','DayOfMonth','Start') + foreach ($item in $valuesToValidate) { - Write-Verbose -Message ($script:localizedData.CurrentSchedule ` - -f $Schedule.RecurInterval, $Schedule.RecurCount) - $result = $false - } - elseif (($state.Schedule) -and ($Schedule.RecurCount -ne 0)) - { - $newSchedule = @{ - RecurInterval = $Schedule.RecurInterval - RecurCount = $Schedule.RecurCount - } - - $desiredSchedule = New-CMSchedule @newSchedule - - $currentSchedule = @{ - RecurInterval = $state.Schedule.RecurInterval - RecurCount = $state.Schedule.RecurCount - } - - $stateSchedule = New-CMSchedule @currentSchedule - - $array = @('DayDuration','DaySpan','HourDuration','HourSpan','IsGMT') - - foreach ($item in $array) + if ($PSBoundParameters.ContainsKey($item)) { - if ($desiredSchedule.$($item) -ne $stateSchedule.$($item)) - { - Write-Verbose -Message ($script:localizedData.ScheduleItem ` - -f $item, $($desiredSchedule.$($item)), $($stateSchedule.$($item))) - $result = $false + $scheduleCheck += @{ + $item = $PSBoundParameters[$item] } } } + + $schedResult = Test-CMSchedule @scheduleCheck -State $state + } + + if ($schedResult -ne $true) + { + $result = $false } } } diff --git a/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.schema.mof b/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.schema.mof index a33210f2..2b48ce9b 100644 --- a/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.schema.mof +++ b/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.schema.mof @@ -5,16 +5,14 @@ class DSC_CMAssetIntelligencePoint: OMI_BaseResource [Required, Description("Specifies the SiteCode for the Configuration Manager site.")] String SiteCode; [Write, Description("Specifies the Site Server to install or configure the role on. If the role is already installed on another server this setting will be ignored.")] String SiteServerName; [Write, Description("Specifies the path to a System Center Online authentication certificate (.pfx) file. If used, this must be in UNC format. Local paths are not allowed. Mutually exclusive with the RemoveCertificate parameter.")] String CertificateFile; - [Write, EmbeddedInstance("DSC_CMAssetIntelligenceSynchronizationSchedule"), Description("Specifies when the asset intelligence catalog is synchronized. (RecurInterval, RecurCount)")] String Schedule; [Write, Description("Specifies whether the installed asset intelligence role is enabled or disabled.")] Boolean Enable; [Write, Description("Specifies whether to synchronize the asset intelligence catalog.")] Boolean EnableSynchronization; [Write, Description("Specifies whether to remove a configured certificate file. Mutually exclusive with the CertificateFile Parameter.")] Boolean RemoveCertificate; [Write, Description("Specifies whether the asset intelligence synchronization point is present or absent."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; -}; - -[ClassVersion("1.0.0")] -class DSC_CMAssetIntelligenceSynchronizationSchedule -{ - [Required, Description("Specifies the recur interval of days."),ValueMap{"Days"},Values{"Days"}] String RecurInterval; - [Required, Description("Specifies how often the recur interval is run.")] UInt32 RecurCount; + [Write, Description("Specifies the start date and start time for the synchronization schedule Month/Day/Year, example 1/1/2020 02:00.")] String Start; + [Write, Description("Specifies the schedule type for the synchronization schedule."), ValueMap{"MonthlyByDay","MonthlyByWeek","Weekly","Days","None"}, Values{"MonthlyByDay","MonthlyByWeek","Weekly","Days","None"}] String ScheduleType; + [Write, Description("Specifies how often the ScheduleType is run.")] UInt32 RecurInterval; + [Write, Description("Specifies week order for MonthlyByWeek schedule type."), ValueMap{"First","Second","Third","Fourth","Last"}, Values{"First","Second","Third","Fourth","Last"}] String MonthlyWeekOrder; + [Write, Description("Specifies the day of week name for MonthlyByWeek and Weekly schedules."), ValueMap{"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}, Values{"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}] String DayOfWeek; + [Write, Description("Specifies the day number for MonthlyByDay schedules.")] UInt32 DayOfMonth; }; diff --git a/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 b/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 index d0f0d9ff..c5777f56 100644 --- a/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 +++ b/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 @@ -8,15 +8,10 @@ ConvertFrom-StringData @' CertMismatch = When specifying a certificate, you can't specify RemoveCertificate as true. SiteServerRole = {0} is not currently a site system server adding site system role. NullCertCheck = Expected no certificate file to be configured, but detected that one is currently configured on {0}. - ScheduleItem = Schedule item {0} expected {1} returned {2}. AddAPRole = Adding Asset Intelligence Synchronization Point role to {0}. SettingValue = Setting value: {0} to {1}. RemoveCert = Removing configured certificate file for site server {0}. RemoveAPRole = Removing Asset Intelligence Synchronization Point role from {0}. - NoSchedule = Expected Schedule to be set to None. - CurrentSchedule = Current Schedule is set to none, desired: {0} {1}. - SetNoSchedule = Setting schedule to none. - SetSchedule = Setting schedule to {0} {1}. RoleInstalled = SiteServerName parameter will be ignored, since role is already installed. ServerNameAdd = Role is not installed, need to specify SiteServerName to add. ServerNameRemove = Role is installed, need to specify SiteServerName to remove. diff --git a/source/Examples/Resources/CMAssetIntelligencePoint/CMAssetIntelligencePoint_Present.ps1 b/source/Examples/Resources/CMAssetIntelligencePoint/CMAssetIntelligencePoint_Present.ps1 index 8fb3eae3..5da3b459 100644 --- a/source/Examples/Resources/CMAssetIntelligencePoint/CMAssetIntelligencePoint_Present.ps1 +++ b/source/Examples/Resources/CMAssetIntelligencePoint/CMAssetIntelligencePoint_Present.ps1 @@ -13,11 +13,8 @@ Configuration Example SiteCode = 'Lab' SiteServerName = 'CA01.contoso.com' Ensure = 'Present' - Schedule = DSC_CMAssetIntelligenceSynchronizationSchedule - { - RecurInterval = 'Days' - RecurCount = '7' - } + ScheduleType = 'Days' + RecurInterval = '7' Enable = $True EnableSynchronization = $True IsSingleInstance = 'Yes' From 677eb76e46dd21e20c870a7580ef6df571c29071 Mon Sep 17 00:00:00 2001 From: Easyreturns <20781445+jeffotterpohl@users.noreply.github.com> Date: Fri, 23 Apr 2021 12:54:09 -0500 Subject: [PATCH 2/6] Updated Pester tests --- .../DSC_CMAssetIntelligencePoint.psm1 | 51 ++- .../DSC_CMAssetIntelligencePoint.strings.psd1 | 1 + tests/Unit/CMAssetIntelligencePoint.tests.ps1 | 392 +++++++++++++++--- 3 files changed, 349 insertions(+), 95 deletions(-) diff --git a/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 b/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 index 73eaf05d..7f8879b2 100644 --- a/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 +++ b/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 @@ -6,7 +6,7 @@ Import-Module -Name $script:configMgrResourcehelper $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' - <# +<# .SYNOPSIS This will return a hashtable of results. @@ -18,7 +18,6 @@ $script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' .Notes This role must only be installed on top-level site of the hierarchy. - #> function Get-TargetResource { @@ -51,8 +50,7 @@ function Get-TargetResource $syncSchedule = $apProps.PeriodicCatalogUpdateSchedule $status = 'Present' - $sSchedule = Convert-CMSchedule -InputObject $syncSchedule - $schedule = Get-CMSchedule -ScheduleString $sSchedule + $schedule = Get-CMSchedule -ScheduleString $syncSchedule } else { @@ -76,7 +74,7 @@ function Get-TargetResource } } - <# +<# .SYNOPSIS This will set the desired state. @@ -272,16 +270,16 @@ function Set-TargetResource } $schedResult = Test-CMSchedule @scheduleCheck -State $state - } - if ($schedResult -eq $false) - { - $sched = Set-CMSchedule @scheduleCheck - $newSchedule = New-CMSchedule @sched + if ($schedResult -eq $false) + { + $sched = Set-CMSchedule @scheduleCheck + $newSchedule = New-CMSchedule @sched - Write-Verbose -Message $script:localizedData.NewSchedule - $buildingParams += @{ - Schedule = $newSchedule + Write-Verbose -Message $script:localizedData.NewSchedule + $buildingParams += @{ + Schedule = $newSchedule + } } } @@ -451,18 +449,17 @@ function Test-TargetResource { Write-Verbose -Message ($script:localizedData.RoleInstalled) - $evalList = @('CertificateFile','Enable','EnableSynchronization') + $testParams = @{ + CurrentValues = $state + DesiredValues = $PSBoundParameters + ValuesToCheck = @('CertificateFile','Enable','EnableSynchronization') + } - foreach ($param in $PSBoundParameters.GetEnumerator()) + $mainState = Test-DscParameterState @testParams -TurnOffTypeChecking -Verbose + + if (-not [string]::IsNullOrEmpty($mainState) -and $mainState -eq $false) { - if ($evalList -contains $param.key) - { - if ($param.Value -ne $state[$param.key]) - { - Write-Verbose -Message ($script:localizedData.TestSetting -f $param.Key, $param.Value, $state[$param.key]) - $result = $false - } - } + $result = $false } if (($RemoveCertificate) -and (-not [string]::IsNullOrEmpty($state.CertificateFile))) @@ -485,11 +482,11 @@ function Test-TargetResource } $schedResult = Test-CMSchedule @scheduleCheck -State $state - } - if ($schedResult -ne $true) - { - $result = $false + if ($schedResult -ne $true) + { + $result = $false + } } } } diff --git a/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 b/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 index c5777f56..476641b7 100644 --- a/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 +++ b/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 @@ -15,4 +15,5 @@ ConvertFrom-StringData @' RoleInstalled = SiteServerName parameter will be ignored, since role is already installed. ServerNameAdd = Role is not installed, need to specify SiteServerName to add. ServerNameRemove = Role is installed, need to specify SiteServerName to remove. + NewSchedule = Modifying Asset Intelligence Syncrhonization schedule. '@ diff --git a/tests/Unit/CMAssetIntelligencePoint.tests.ps1 b/tests/Unit/CMAssetIntelligencePoint.tests.ps1 index 022cc15c..e4628484 100644 --- a/tests/Unit/CMAssetIntelligencePoint.tests.ps1 +++ b/tests/Unit/CMAssetIntelligencePoint.tests.ps1 @@ -1,3 +1,4 @@ +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')] param () $script:dscModuleName = 'ConfigMgrCBDsc' @@ -36,7 +37,7 @@ Invoke-TestSetup try { InModuleScope $script:dscResourceName { - $moduleResourceName = 'ConfigMgrCBDsc - DSC_CMAssetIntelligencePoint' + <#$moduleResourceName = 'ConfigMgrCBDsc - DSC_CMAssetIntelligencePoint' $mockCimSchedule = (New-CimInstance -ClassName DSC_CMAssetIntelligenceSynchronizationSchedule ` -Namespace root/microsoft/Windows/DesiredStateConfiguration ` @@ -261,10 +262,63 @@ try $networkOSPath = @{ NetworkOSPath = '\\CA01.Contoso.com' - } + }#> - Describe "$moduleResourceName\Get-TargetResource" { + Describe 'ConfigMgrCBDsc - DSC_CMAssetIntelligencePoint\Get-TargetResource' -Tag 'Get' { BeforeAll{ + $getInput = @{ + SiteCode = 'Lab' + IsSingleInstance = 'Yes' + } + + $getAPReturnNoCert = @{ + SiteCode = 'Lab' + ProxyName = 'CA01.contoso.com' + ProxyCertPath = $null + ProxyEnabled = $true + PeriodicCatalogUpdateEnabled = $true + PeriodicCatalogUpdateSchedule = '0001200000100038' + IsSingleInstance = 'Yes' + } + + $getAPReturnWithCert = @{ + SiteCode = 'Lab' + ProxyName = 'CA01.contoso.com' + ProxyCertPath = '\\CA01.Contoso.com\c$\cert.pfx' + ProxyEnabled = $true + PeriodicCatalogUpdateEnabled = $true + PeriodicCatalogUpdateSchedule = '0001200000100038' + IsSingleInstance = 'Yes' + } + + $networkOSPath = @{ + NetworkOSPath = '\\CA01.Contoso.com' + } + + $getDayScheduleReturn = @{ + MinuteDuration = $null + RecurInterval = 5 + WeekOrder = $null + HourDuration = $null + Start = '2/1/1970 00:00' + DayOfWeek = $null + ScheduleType = 'Days' + MonthDay = $null + DayDuration = $null + } + + $getMonthlyByWeek = @{ + MinuteDuration = $null + RecurInterval = 1 + WeekOrder = 'First' + HourDuration = $null + Start = '2/1/1970 00:00' + DayOfWeek = 'Friday' + ScheduleType = 'MonthlyByWeek' + MonthDay = $null + DayDuration = $null + } + Mock -CommandName Import-ConfigMgrPowerShellModule Mock -CommandName Set-Location } @@ -274,66 +328,160 @@ try It 'Should return desired result when asset intelligence point is not currently installed' { Mock -CommandName Get-CMAssetIntelligenceProxy -MockWith { $null } Mock -CommandName Get-CMAssetIntelligenceSynchronizationPoint -MockWith { $null } - Mock -CommandName ConvertTo-CimCMScheduleString -MockWith { $null } + Mock -CommandName Get-CMSchedule -MockWith { $null } $result = Get-TargetResource @getInput $result | Should -BeOfType System.Collections.HashTable $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.IsSingleInstance | Should -Be -ExpectedValue 'Yes' $result.SiteServerName | Should -Be -ExpectedValue $null $result.CertificateFile | Should -Be -ExpectedValue $null $result.Enable | Should -Be -ExpectedValue $null $result.EnableSynchronization | Should -Be -ExpectedValue $null - $result.Schedule | Should -Be -ExpectedValue $null + $result.Start | Should -Be -ExpectedValue $null + $result.ScheduleType | Should -Be -ExpectedValue $null + $result.DayOfWeek | Should -Be -ExpectedValue $null + $result.MonthlyWeekOrder | Should -Be -ExpectedValue $null + $result.DayOfMonth | Should -Be -ExpectedValue $null + $result.RecurInterval | Should -Be -ExpectedValue $null $result.Ensure | Should -Be -ExpectedValue 'Absent' } It 'Should return desired result when asset intelligence point is currently installed with no certificate file' { Mock -CommandName Get-CMAssetIntelligenceProxy -MockWith { $getAPReturnNoCert } Mock -CommandName Get-CMAssetIntelligenceSynchronizationPoint -MockWith { $networkOSPath } - Mock -CommandName ConvertTo-CimCMScheduleString -MockWith { $mockCimSchedule } + Mock -CommandName Get-CMSchedule -MockWith { $getDayScheduleReturn } $result = Get-TargetResource @getInput $result | Should -BeOfType System.Collections.HashTable + $result.IsSingleInstance | Should -Be -ExpectedValue 'Yes' $result.SiteCode | Should -Be -ExpectedValue 'Lab' $result.SiteServerName | Should -Be -ExpectedValue 'CA01.contoso.com' $result.CertificateFile | Should -Be -ExpectedValue $null $result.Enable | Should -Be -ExpectedValue $true $result.EnableSynchronization | Should -Be -ExpectedValue $true - $result.Schedule | Should -Match $mockCimSchedule - $result.Schedule | Should -BeOfType '[Microsoft.Management.Infrastructure.CimInstance]' + $result.Start | Should -Be -ExpectedValue '2/1/1970 00:00' + $result.ScheduleType | Should -Be -ExpectedValue 'Days' + $result.DayOfWeek | Should -Be -ExpectedValue $null + $result.MonthlyWeekOrder | Should -Be -ExpectedValue $null + $result.DayOfMonth | Should -Be -ExpectedValue $null + $result.RecurInterval | Should -Be -ExpectedValue 5 $result.Ensure | Should -Be -ExpectedValue 'Present' } It 'Should return desired result when asset intelligence point is currently installed with a certificate file' { Mock -CommandName Get-CMAssetIntelligenceProxy -MockWith { $getAPReturnWithCert } Mock -CommandName Get-CMAssetIntelligenceSynchronizationPoint -MockWith { $networkOSPath } - Mock -CommandName ConvertTo-CimCMScheduleString -MockWith { $mockCimSchedule } + Mock -CommandName Get-CMSchedule -MockWith { $getMonthlyByWeek } $result = Get-TargetResource @getInput $result | Should -BeOfType System.Collections.HashTable + $result.IsSingleInstance | Should -Be -ExpectedValue 'Yes' $result.SiteCode | Should -Be -ExpectedValue 'Lab' $result.SiteServerName | Should -Be -ExpectedValue 'CA01.contoso.com' $result.CertificateFile | Should -Be -ExpectedValue '\\CA01.Contoso.com\c$\cert.pfx' $result.Enable | Should -Be -ExpectedValue $true $result.EnableSynchronization | Should -Be -ExpectedValue $true - $result.Schedule | Should -Match $mockCimSchedule - $result.Schedule | Should -BeOfType '[Microsoft.Management.Infrastructure.CimInstance]' + $result.Start | Should -Be -ExpectedValue '2/1/1970 00:00' + $result.ScheduleType | Should -Be -ExpectedValue 'MonthlyByWeek' + $result.DayOfWeek | Should -Be -ExpectedValue 'Friday' + $result.MonthlyWeekOrder | Should -Be -ExpectedValue 'First' + $result.DayOfMonth | Should -Be -ExpectedValue $null + $result.RecurInterval | Should -Be -ExpectedValue 1 $result.Ensure | Should -Be -ExpectedValue 'Present' } } } - Describe "$moduleResourceName\Set-TargetResource" { + Describe 'ConfigMgrCBDsc - DSC_CMAssetIntelligencePoint\Set-TargetResource' -Tag 'Set' { + BeforeAll { + $getReturnAll = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + CertificateFile = '\\CA01.Contoso.com\c$\cert.pfx' + Enable = $true + EnableSynchronization = $true + Start = '2/1/1970 00:00' + ScheduleType = 'Days' + DayOfWeek = $null + MonthlyWeekOrder = $null + DayOfMonth = $null + RecurInterval = '5' + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + + $getReturnAbsent = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + CertificateFile = $null + Enable = $null + EnableSynchronization = $null + Schedule = $null + Ensure = 'Absent' + IsSingleInstance = 'Yes' + } + + $inputAbsent = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + Ensure = 'Absent' + IsSingleInstance = 'Yes' + } + + Mock -CommandName Import-ConfigMgrPowerShellModule + Mock -CommandName Set-Location + Mock -CommandName Get-CMSiteSystemServer + Mock -CommandName New-CMSiteSystemServer + Mock -CommandName Add-CMAssetIntelligenceSynchronizationPoint + Mock -CommandName Set-CMAssetIntelligenceSynchronizationPoint + Mock -CommandName Remove-CMAssetIntelligenceSynchronizationPoint + Mock -CommandName New-CMSChedule + } + Context 'When Set-TargetResource runs successfully' { - BeforeEach{ - Mock -CommandName Import-ConfigMgrPowerShellModule - Mock -CommandName Set-Location - Mock -CommandName Get-CMSiteSystemServer - Mock -CommandName New-CMSiteSystemServer - Mock -CommandName Add-CMAssetIntelligenceSynchronizationPoint - Mock -CommandName New-CMSchedule - Mock -CommandName Set-CMAssetIntelligenceSynchronizationPoint - Mock -CommandName Remove-CMAssetIntelligenceSynchronizationPoint + BeforeEach { + $inputNoSync = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + Enable = $true + EnableSynchronization = $false + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + + $inputNoCert = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + Enable = $true + EnableSynchronization = $true + RemoveCertificate = $true + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + + $inputPresentSchedule = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + EnableSynchronization = $true + Ensure = 'Present' + IsSingleInstance = 'Yes' + ScheduleType = 'Weekly' + RecurInterval = 1 + DayOfWeek = 'Monday' + Start = '1/1/2021 01:00' + } + + $scheduleReturn = @{ + DurationInterval = 'Minutes' + DurationCount = 59 + RecurCount = 1 + DayOfWeek = 'Monday' + } + + Mock -CommandName Test-CMSchedule -MockWith { $false } + + Mock -CommandName Set-CMSchedule -MockWith { $scheduleReturn } } It 'Should call expected commands for when changing settings' { @@ -346,6 +494,8 @@ try Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -Scope It + Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It @@ -362,6 +512,8 @@ try Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 1 -Scope It Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 1 -Scope It Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It + Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -Scope It + Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It @@ -377,44 +529,48 @@ try Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -Scope It + Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It } - It 'Should call expected commands when changing the schedule' { - Mock -CommandName Get-TargetResource -MockWith { $returnEnabledDaysMismatch } - Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertDays } -ParameterFilter { $RecurCount -eq 7 } - Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertDaysMismatch } -ParameterFilter { $RecurCount -eq 6 } + It 'Should call expected commands when asset intelligence point exists and expected absent' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } - Set-TargetResource @getReturnEnabledDays + Set-TargetResource @inputAbsent Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSchedule -Exactly -Times 2 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -Scope It + Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -Scope It + Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It + Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It } - It 'Should call expected commands when asset intelligence point exists and expected absent' { + It 'Should call expected commands when changing the schedule' { Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } - Set-TargetResource @inputAbsent + Set-TargetResource @inputPresentSchedule Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It + Assert-MockCalled Test-CMSchedule -Exactly -Times 1 -Scope It + Assert-MockCalled Set-CMSchedule -Exactly -Times 1 -Scope It + Assert-MockCalled New-CMSchedule -Exactly -Times 1 -Scope It + Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It + Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It } - It 'Should call expected commands when a schedule is present and a nonrecurring schedule is specified' { + <#It 'Should call expected commands when a schedule is present and a nonrecurring schedule is specified' { Mock -CommandName Get-TargetResource -MockWith { $getReturnEnabledDays } Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertZero } @@ -425,6 +581,8 @@ try Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -ScopeIt + Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -ScopeIt Assert-MockCalled New-CMSchedule -Exactly -Times 1 -Scope It Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It @@ -441,6 +599,8 @@ try Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -ScopeIt + Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -ScopeIt Assert-MockCalled New-CMSchedule -Exactly -Times 1 -Scope It Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It @@ -457,22 +617,55 @@ try Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 1 -Scope It Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 1 -Scope It Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It + Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -ScopeIt + Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -ScopeIt Assert-MockCalled New-CMSchedule -Exactly -Times 1 -Scope It Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - } + }#> } Context 'When Set-TargetResource throws' { - BeforeEach{ - Mock -CommandName Import-ConfigMgrPowerShellModule - Mock -CommandName Set-Location - Mock -CommandName Get-CMSiteSystemServer - Mock -CommandName New-CMSiteSystemServer - Mock -CommandName Add-CMAssetIntelligenceSynchronizationPoint + BeforeEach { + $syncScheduleThrow = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + EnableSynchronization = $false + ScheduleType = 'Days' + RecurInterval = 1 + IsSingleInstance = 'Yes' + } + + $syncScheduleThrowMsg = 'When specifying a schedule, the EnableSynchronization paramater must be true.' + + $certThrow = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + RemoveCertificate = $true + CertificateFile = '\\CA01.Contoso.com\c$\cert.pfx' + IsSingleInstance = 'Yes' + } + + $certThrowMsg = "When specifying a certificate, you can't specify RemoveCertificate as true." + + $installThrow = @{ + SiteCode = 'Lab' + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + + $installThrowMsg = 'Role is not installed, need to specify SiteServerName to add.' + + $removeThrow = @{ + SiteCode = 'Lab' + Ensure = 'Absent' + IsSingleInstance = 'Yes' + } + + $removeThrowMsg = 'Role is installed, need to specify SiteServerName to remove.' + + Mock -CommandName Test-CMSchedule Mock -CommandName New-CMSchedule - Mock -CommandName Set-CMAssetIntelligenceSynchronizationPoint - Mock -CommandName Remove-CMAssetIntelligenceSynchronizationPoint } It 'Should call throws when a schedule is specified and enable synchronization is false' { @@ -535,7 +728,7 @@ try Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It } - It 'Should call expected commands and throw if Get-CMSiteSystemServer throws' { + <#It 'Should call expected commands and throw if Get-CMSiteSystemServer throws' { Mock -CommandName Get-TargetResource -MockWith { $getReturnAbsent } Mock -CommandName Get-CMSiteSystemServer -MockWith { throw } @@ -632,12 +825,92 @@ try Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - } + }#> } } - Describe "$moduleResourceName\Test-TargetResource" { - BeforeAll{ + Describe 'ConfigMgrCBDsc - DSC_CMAssetIntelligencePoint\Test-TargetResource' -Tag 'Test' { + BeforeAll { + $getReturnAbsent = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + CertificateFile = $null + Enable = $null + EnableSynchronization = $null + Schedule = $null + Ensure = 'Absent' + IsSingleInstance = 'Yes' + } + + $inputAbsent = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + Ensure = 'Absent' + IsSingleInstance = 'Yes' + } + + $inputPresent = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + + $inputPresentSchedule = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + Ensure = 'Present' + IsSingleInstance = 'Yes' + ScheduleType = 'Weekly' + RecurInterval = 1 + DayOfWeek = 'Monday' + Start = '1/1/2021 01:00' + } + + $inputUseCert = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + CertificateFile = '\\CA01.Contoso.com\c$\cert.pfx' + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + + $inputNoCert = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + Enable = $true + EnableSynchronization = $true + RemoveCertificate = $true + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + + $getReturnAll = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + CertificateFile = '\\CA01.Contoso.com\c$\cert.pfx' + Enable = $true + EnableSynchronization = $true + Start = '2/1/1970 00:00' + ScheduleType = 'Days' + DayOfWeek = $null + MonthlyWeekOrder = $null + DayOfMonth = $null + RecurInterval = '5' + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + + $getReturnNoCert = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + CertificateFile = $null + Enable = $true + EnableSynchronization = $true + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + Mock -CommandName Set-Location Mock -CommandName Import-ConfigMgrPowerShellModule } @@ -686,27 +959,10 @@ try Test-TargetResource @inputUseCert | Should -Be $false } - It 'Should return desired result false schedule days mismatch' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnEnabledDays } - Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertDays } -ParameterFilter { $RecurCount -eq 7 } - Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertDaysMismatch } -ParameterFilter { $RecurCount -eq 6 } - Test-TargetResource @returnEnabledDaysMismatch | Should -Be $false - } - - It 'Should return desired result true schedule matches' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } - Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertDays } - Test-TargetResource @getReturnAll | Should -Be $true - } - - It 'Should return desired result false schedule present but nonrecurring specified' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnEnabledDays } - Test-TargetResource @getReturnEnabledZero | Should -Be $false - } + It 'Should return desired result false when a schedule does not match' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnNoCert } - It 'Should return desired result false no schedule present but schedule specified' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnNoSchedule } - Test-TargetResource @getReturnEnabledDays | Should -Be $false + Test-TargetResource @inputPresentSchedule | Should -Be $false } } } From c440d489ff653db35d3c89977ca1548f6dd77435 Mon Sep 17 00:00:00 2001 From: Easyreturns <20781445+jeffotterpohl@users.noreply.github.com> Date: Fri, 23 Apr 2021 12:55:18 -0500 Subject: [PATCH 3/6] removed dead code from Pester --- tests/Unit/CMAssetIntelligencePoint.tests.ps1 | 227 ------------------ 1 file changed, 227 deletions(-) diff --git a/tests/Unit/CMAssetIntelligencePoint.tests.ps1 b/tests/Unit/CMAssetIntelligencePoint.tests.ps1 index e4628484..2e7c0678 100644 --- a/tests/Unit/CMAssetIntelligencePoint.tests.ps1 +++ b/tests/Unit/CMAssetIntelligencePoint.tests.ps1 @@ -37,233 +37,6 @@ Invoke-TestSetup try { InModuleScope $script:dscResourceName { - <#$moduleResourceName = 'ConfigMgrCBDsc - DSC_CMAssetIntelligencePoint' - - $mockCimSchedule = (New-CimInstance -ClassName DSC_CMAssetIntelligenceSynchronizationSchedule ` - -Namespace root/microsoft/Windows/DesiredStateConfiguration ` - -Property @{ - 'RecurInterval' = 'Days' - 'RecurCount' = 7 - } -ClientOnly - ) - - $mockCimScheduleDayMismatch = (New-CimInstance -ClassName DSC_CMAssetIntelligenceSynchronizationSchedule ` - -Namespace root/microsoft/Windows/DesiredStateConfiguration ` - -Property @{ - 'RecurInterval' = 'Days' - 'RecurCount' = 6 - } -ClientOnly - ) - - $mockCimScheduleZero = (New-CimInstance -ClassName DSC_CMAssetIntelligenceSynchronizationSchedule ` - -Namespace root/microsoft/Windows/DesiredStateConfiguration ` - -Property @{ - 'RecurInterval' = 'Days' - 'RecurCount' = 0 - } -ClientOnly - ) - - $scheduleConvertDays = @{ - DayDuration = 0 - DaySpan = 7 - HourDuration = 0 - HourSpan = 0 - MinuteDuration = 0 - MinuteSpan = 0 - } - - $scheduleConvertDaysMismatch = @{ - DayDuration = 0 - DaySpan = 6 - HourDuration = 0 - HourSpan = 0 - MinuteDuration = 0 - MinuteSpan = 0 - } - - $scheduleConvertZero = @{ - DayDuration = 0 - HourDuration = 0 - IsGMT = $false - MinuteDuration = 0 - } - - $returnEnabledDaysMismatch = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - Schedule = $mockCimScheduleDayMismatch - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $getReturnEnabledZero = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - Schedule = $mockCimScheduleZero - EnableSynchronization = $true - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $getInput = @{ - SiteCode = 'Lab' - IsSingleInstance = 'Yes' - } - - $getAPReturnNoCert = @{ - SiteCode = 'Lab' - ProxyName = 'CA01.contoso.com' - ProxyCertPath = $null - ProxyEnabled = $true - PeriodicCatalogUpdateEnabled = $true - PeriodicCatalogUpdateSchedule = '0001200000100038' - IsSingleInstance = 'Yes' - } - - $getAPReturnWithCert = @{ - SiteCode = 'Lab' - ProxyName = 'CA01.contoso.com' - ProxyCertPath = '\\CA01.Contoso.com\c$\cert.pfx' - ProxyEnabled = $true - PeriodicCatalogUpdateEnabled = $true - PeriodicCatalogUpdateSchedule = '0001200000100038' - IsSingleInstance = 'Yes' - } - - $getReturnAbsent = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - CertificateFile = $null - Enable = $null - EnableSynchronization = $null - Schedule = $null - Ensure = 'Absent' - IsSingleInstance = 'Yes' - } - - $getReturnAll = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - CertificateFile = '\\CA01.Contoso.com\c$\cert.pfx' - Enable = $true - EnableSynchronization = $true - Schedule = $mockCimSchedule - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $getReturnEnabledDays = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - CertificateFile = $null - Enable = $true - EnableSynchronization = $true - Schedule = $mockCimSchedule - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $getReturnNoSchedule = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - CertificateFile = $null - Enable = $true - EnableSynchronization = $true - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $getReturnNoCert = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - CertificateFile = $null - Enable = $true - EnableSynchronization = $true - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $inputAbsent = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - Ensure = 'Absent' - IsSingleInstance = 'Yes' - } - - $inputPresent = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $inputUseCert = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - CertificateFile = '\\CA01.Contoso.com\c$\cert.pfx' - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $inputNoCert = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - Enable = $true - EnableSynchronization = $true - RemoveCertificate = $true - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $inputNoSync = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - Enable = $true - EnableSynchronization = $false - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $syncScheduleThrow = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - EnableSynchronization = $false - Schedule = $mockCimSchedule - IsSingleInstance = 'Yes' - } - - $syncScheduleThrowMsg = 'When specifying a schedule, the EnableSynchronization paramater must be true.' - - $certThrow = @{ - SiteCode = 'Lab' - SiteServerName = 'CA01.contoso.com' - RemoveCertificate = $true - CertificateFile = '\\CA01.Contoso.com\c$\cert.pfx' - IsSingleInstance = 'Yes' - } - - $certThrowMsg = "When specifying a certificate, you can't specify RemoveCertificate as true." - - $installThrow = @{ - SiteCode = 'Lab' - Ensure = 'Present' - IsSingleInstance = 'Yes' - } - - $installThrowMsg = 'Role is not installed, need to specify SiteServerName to add.' - - $removeThrow = @{ - SiteCode = 'Lab' - Ensure = 'Absent' - IsSingleInstance = 'Yes' - } - - $removeThrowMsg = 'Role is installed, need to specify SiteServerName to remove.' - - $networkOSPath = @{ - NetworkOSPath = '\\CA01.Contoso.com' - }#> - Describe 'ConfigMgrCBDsc - DSC_CMAssetIntelligencePoint\Get-TargetResource' -Tag 'Get' { BeforeAll{ $getInput = @{ From 7a415b895e3d92cc4dc813a3bf3b11b36d2e260a Mon Sep 17 00:00:00 2001 From: Nick Ellis Date: Mon, 10 May 2021 09:02:29 -0400 Subject: [PATCH 4/6] Updating Write-Warning statements in Test --- .../DSC_CMAssetIntelligencePoint.psm1 | 30 +++- tests/Unit/CMAssetIntelligencePoint.tests.ps1 | 168 ++---------------- 2 files changed, 36 insertions(+), 162 deletions(-) diff --git a/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 b/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 index 7f8879b2..8bd451bf 100644 --- a/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 +++ b/source/DSCResources/DSC_CMAssetIntelligencePoint/DSC_CMAssetIntelligencePoint.psm1 @@ -203,18 +203,18 @@ function Set-TargetResource try { - if (($ScheduleType) -and ($EnableSynchronization -eq $false)) + if ($Ensure -eq 'Present') { - throw $script:localizedData.ScheduleNoSync - } + if (($ScheduleType) -and ($EnableSynchronization -eq $false)) + { + throw $script:localizedData.ScheduleNoSync + } - if (($CertificateFile) -and ($RemoveCertificate -eq $true)) - { - throw $script:localizedData.CertMismatch - } + if (($CertificateFile) -and ($RemoveCertificate -eq $true)) + { + throw $script:localizedData.CertMismatch + } - if ($Ensure -eq 'Present') - { if ($state.Ensure -eq 'Absent') { if (-not $PsBoundParameters.ContainsKey('SiteServerName')) @@ -440,6 +440,18 @@ function Test-TargetResource if ($Ensure -eq 'Present') { + if (($ScheduleType) -and ($EnableSynchronization -eq $false)) + { + Write-Warning -Message $script:localizedData.ScheduleNoSync + $result = $false + } + + if (($CertificateFile) -and ($RemoveCertificate -eq $true)) + { + Write-Warning -Message $script:localizedData.CertMismatch + $result = $false + } + if ($state.Ensure -eq 'Absent') { Write-Verbose -Message ($script:localizedData.APNotInstalled -f $SiteServerName) diff --git a/tests/Unit/CMAssetIntelligencePoint.tests.ps1 b/tests/Unit/CMAssetIntelligencePoint.tests.ps1 index 2e7c0678..ef8ce5d8 100644 --- a/tests/Unit/CMAssetIntelligencePoint.tests.ps1 +++ b/tests/Unit/CMAssetIntelligencePoint.tests.ps1 @@ -342,60 +342,6 @@ try Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It } - - <#It 'Should call expected commands when a schedule is present and a nonrecurring schedule is specified' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnEnabledDays } - Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertZero } - - Set-TargetResource @getReturnEnabledZero - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -ScopeIt - Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -ScopeIt - Assert-MockCalled New-CMSchedule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - } - - It 'Should call expected commands when no schedule is present and a schedule is specified' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnNoSchedule } - Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertDays } - - Set-TargetResource @getReturnEnabledDays - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -ScopeIt - Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -ScopeIt - Assert-MockCalled New-CMSchedule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - } - - It 'Should call expected commands when a state is absent and a nonrecurring schedule is specified' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnAbsent } - Mock -CommandName New-CMSchedule -MockWith { $scheduleConvertZero } - - Set-TargetResource @getReturnEnabledZero - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 1 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 1 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - Assert-MockCalled Test-CMSchedule -Exactly -Times 0 -ScopeIt - Assert-MockCalled Set-CMSchedule -Exactly -Times 0 -ScopeIt - Assert-MockCalled New-CMSchedule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - }#> } Context 'When Set-TargetResource throws' { @@ -500,105 +446,6 @@ try Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It } - - <#It 'Should call expected commands and throw if Get-CMSiteSystemServer throws' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnAbsent } - Mock -CommandName Get-CMSiteSystemServer -MockWith { throw } - - { Set-TargetResource @inputPresent } | Should -Throw - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 1 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - } - - It 'Should call expected commands and throw if New-CMSiteSystemServer throws' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnAbsent } - Mock -CommandName Get-CMSiteSystemServer - Mock -CommandName New-CMSiteSystemServer -MockWith { throw } - - { Set-TargetResource @inputPresent } | Should -Throw - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 1 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 1 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - } - - It 'Should call expected commands and throw if Add-CMAssetIntelligenceSynchronizationPoint throws' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnAbsent } - Mock -CommandName Get-CMSiteSystemServer - Mock -CommandName New-CMSiteSystemServer -MockWith { $true } - Mock -CommandName Add-CMAssetIntelligenceSynchronizationPoint -MockWith { throw } - - { Set-TargetResource @inputNoCert } | Should -Throw - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 1 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 1 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - } - - It 'Should call expected commands and throw if New-CMSchedule throws' { - Mock -CommandName Get-TargetResource -MockWith { $returnEnabledDaysMismatch } - Mock -CommandName New-CMSchedule -MockWith { throw } - - { Set-TargetResource @getReturnEnabledDays } | Should -Throw - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSchedule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - } - - It 'Should call expected commands and throw if Set-CMAssetIntelligenceSynchronizationPoint throws' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } - Mock -CommandName Set-CMAssetIntelligenceSynchronizationPoint -MockWith { throw } - - { Set-TargetResource @inputNoSync } | Should -Throw - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - } - - It 'Should call expected commands and throw if Remove-CMAssetIntelligenceSynchronizationPoint throws' { - Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } - Mock -CommandName Remove-CMAssetIntelligenceSynchronizationPoint -MockWith { throw } - - { Set-TargetResource @inputAbsent } | Should -Throw - Assert-MockCalled Import-ConfigMgrPowerShellModule -Exactly -Times 1 -Scope It - Assert-MockCalled Set-Location -Exactly -Times 2 -Scope It - Assert-MockCalled Get-TargetResource -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSiteSystemServer -Exactly -Times 0 -Scope It - Assert-MockCalled Add-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled New-CMSchedule -Exactly -Times 0 -Scope It - Assert-MockCalled Set-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It - Assert-MockCalled Remove-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It - }#> } } @@ -648,6 +495,15 @@ try IsSingleInstance = 'Yes' } + $inputCertNoCert = @{ + SiteCode = 'Lab' + SiteServerName = 'CA01.contoso.com' + CertificateFile = '\\CA01.Contoso.com\c$\cert.pfx' + RemoveCertificate = $true + Ensure = 'Present' + IsSingleInstance = 'Yes' + } + $inputNoCert = @{ SiteCode = 'Lab' SiteServerName = 'CA01.contoso.com' @@ -720,6 +576,12 @@ try Test-TargetResource @inputNoCert | Should -Be $false } + It 'Should return desired result false when a certificate file is specified along with RemoveCertificate being set to true' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Test-TargetResource @inputCertNoCert | Should -Be $false + } + It 'Should return desired result true when no certificate file is specified and no certificate file is present' { Mock -CommandName Get-TargetResource -MockWith { $getReturnNoCert } From 4bfad54763bf7e0a9d927f66baca4911471fca6a Mon Sep 17 00:00:00 2001 From: Nick Ellis Date: Mon, 10 May 2021 09:27:08 -0400 Subject: [PATCH 5/6] Removing Unnecessary String --- .../en-US/DSC_CMAssetIntelligencePoint.strings.psd1 | 1 - 1 file changed, 1 deletion(-) diff --git a/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 b/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 index 476641b7..b66f9321 100644 --- a/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 +++ b/source/DSCResources/DSC_CMAssetIntelligencePoint/en-US/DSC_CMAssetIntelligencePoint.strings.psd1 @@ -1,7 +1,6 @@ ConvertFrom-StringData @' RetrieveSettingValue = Getting information for the specified Asset Intelligence Synchronization Point. APNotInstalled = Asset Intelligence Synchronization Point is not installed on server: {0}. - TestSetting = Setting {0} expected value: {1} returned {2}. APAbsent = {0} Asset Intelligence Synchronization Point expected absent returned present. TestState = Test-TargetResource compliance check returned: {0}. ScheduleNoSync = When specifying a schedule, the EnableSynchronization paramater must be true. From c54a91023838cec585173eb89592cd4a76811b12 Mon Sep 17 00:00:00 2001 From: Nick Ellis Date: Mon, 10 May 2021 10:10:09 -0400 Subject: [PATCH 6/6] Addressing PR Comments --- CHANGELOG.md | 2 +- README.md | 2 +- tests/Unit/CMAssetIntelligencePoint.tests.ps1 | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6fdcbeb..ac36ce08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,7 +100,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added additional schedule types for CMCollections schedules. - Updated CMSystemDiscovery to warn when exceeding max allowed hours or days or minutes and when specifying under the minimum allowed minutes. -- Updated CMAssetIntelligencePoint to use the helper functions for scheduling. +- Updated CMAssetIntelligencePoint to use the helper function for scheduling. ### Removed diff --git a/README.md b/README.md index 66ea609c..34ac7a6d 100644 --- a/README.md +++ b/README.md @@ -583,7 +583,7 @@ you are using apply and auto correct. - **[String] IsSingleInstance** _(Key)_: Specifies the resource is a single instance, the value must be 'Yes'. - { Yes }. + - Values include: { Yes }. - **[String] SiteCode** _(Key)_: Specifies the Site Code for the Configuration Manager site. - **[String] SiteServerName** _(Required)_: Specifies the Site Server to install diff --git a/tests/Unit/CMAssetIntelligencePoint.tests.ps1 b/tests/Unit/CMAssetIntelligencePoint.tests.ps1 index ef8ce5d8..5da11000 100644 --- a/tests/Unit/CMAssetIntelligencePoint.tests.ps1 +++ b/tests/Unit/CMAssetIntelligencePoint.tests.ps1 @@ -38,7 +38,7 @@ try { InModuleScope $script:dscResourceName { Describe 'ConfigMgrCBDsc - DSC_CMAssetIntelligencePoint\Get-TargetResource' -Tag 'Get' { - BeforeAll{ + BeforeAll { $getInput = @{ SiteCode = 'Lab' IsSingleInstance = 'Yes' @@ -253,7 +253,6 @@ try } Mock -CommandName Test-CMSchedule -MockWith { $false } - Mock -CommandName Set-CMSchedule -MockWith { $scheduleReturn } }