diff --git a/CHANGELOG.md b/CHANGELOG.md index fb873eb..02d3565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added CMClientSettingsSoftwareUpdate resource - Added CMClientSettingsStateMessaging resource - Added CMClientSettingsUserDeviceAffinity resource +- Added CMSiteConfiguration resource ### Fixed diff --git a/README.md b/README.md index a1c2027..5beeac6 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,8 @@ Please check out common DSC Community [contributing guidelines](https://dsccommu client policy settings for State Messaging settings. - **CMClientSettingsUserDeviceAffinity**: Provides a resource for modifying the client policy settings for User Device Affinity settings. +- **CMSiteConfiguration**: Provides a resource for modifying the + site settings. ### xSccmPreReqs @@ -2069,6 +2071,111 @@ you are using apply and auto correct. - [CMClientSettingsUserDeviceAffinity](Source\Examples\Resources\CMClientSettingsUserDeviceAffinity\CMClientSettingsUserDeviceAffinity.ps1) +### CMSiteConfiguration + +- **[String] SiteCode** _(Key)_: Specifies the Site Code for the Configuration + Manager site. +- **[String] Comment** _(Write)_: Specifies the site comments. +- **[String] ClientComputerCommunicationType** _(Write)_: Specifies the communication + method for the site systems that use IIS. To use HTTPS, the servers need a valid + PKI web server certificate for server authentication. + This parameter is only valid on a Primary Site. + - Values include: { HttpsOnly | HttpsOrHttp } +- **[Boolean] ClientCheckCertificateRevocationListForSiteSystem** _(Write)_: Indicates + whether clients check the Certificate Revocation List (CRL) for site systems. + This parameter is only valid on a Primary Site. +- **[Boolean] UsePkiClientCertificate** _(Write)_: Indicates whether to use a PKI + client certificate for client authentication when available. + This parameter is only valid on a Primary Site. +- **[Boolean] UseSmsGeneratedCert** _(Write)_: Use this parameter to enable or disable + the site property to Use Configuration Manager-generated certificates for HTTP + site systems. + This parameter is only valid on a Primary Site. +- **[Boolean] RequireSigning** _(Write)_: This option requires that clients sign + data when they send to management points. + This parameter is only valid on a Primary Site. +- **[Boolean] RequireSha256** _(Write)_: Specifies if the clients sign data and + communicate with site systems by using HTTP, this option requires the clients + to use SHA-256 to sign the data. This option applies to clients that don't use + PKI certificates. + This parameter is only valid on a Primary Site. +- **[Boolean] UseEncryption** _(Write)_: Specifies to use 3DES to encrypt the client + inventory data and state messages that are sent to the management point. + This parameter is only valid on a Primary Site. +- **[UInt32] MaximumConcurrentSendingForAllSite** _(Write)_: Specifies the maximum + number of simultaneous communications to all sites. +- **[UInt32] MaximumConcurrentSendingForPerSite** _(Write)_: Specifies the maximum + number of simultaneous communications to any single site. +- **[UInt32] RetryNumberForConcurrentSending** _(Write)_: Specifies the number of + times to retry a failed communication. +- **[UInt32] ConcurrentSendingDelayBeforeRetryingMins** _(Write)_: Specifies the + number of minutes to delay before it retries. +- **[Boolean] EnableLowFreeSpaceAlert** _(Write)_: Specifies if an alert is created + when the free disk space on the site database server is low. + This parameter is only valid on a Primary Site. +- **[UInt32] FreeSpaceThresholdWarningGB** _(Write)_: Specifies disk space warning + alert when the free disk space on the site database server falls below the specified + threshold. + This parameter is only valid on a Primary Site. +- **[UInt32] FreeSpaceThresholdCriticalGB** _(Write)_: Specifies disk space critical + alert when the free disk space on the site database server falls below the specified + threshold. + This parameter is only valid on a Primary Site. +- **[UInt32] ThresholdOfSelectCollectionByDefault** _(Write)_: Specifies select collection + window hides collections with membership that exceeds this value. +- **[UInt32] ThresholdOfSelectCollectionMax** _(Write)_: Specifies select collection + window always hides collections that have more members than this maximum value. +- **[String] SiteSystemCollectionBehavior** _(Write)_: Specifies the behavior to + take when the selected collection includes computers that host site systems roles. + - Values include: { Warn | Block } +- **[Boolean] EnableWakeOnLan** _(Write)_: Indicates whether to send Wake On LAN + packets for scheduled activities such as deployments of software updates. + This parameter is only valid on a Primary Site. +- **[String] WakeOnLanTransmissionMethodType** _(Write)_: Specifies the type of + transmission method to use for Wake On LAN transmissions. + This parameter is only valid on a Primary Site. + - Values include: { Unicast | SubnetDirectedBroadcasts } +- **[UInt32] RetryNumberOfSendingWakeupPacketTransmission** _(Write)_: Specifies + the number of times a wake up packet is sent to a target computer. + This parameter is only valid on a Primary Site. +- **[UInt32] SendingWakeupPacketTransmissionDelayMins** _(Write)_: Specifies the + number of minutes to delay between wake up retries. + This parameter is only valid on a Primary Site. +- **[UInt32] MaximumNumberOfSendingWakeupPacketBeforePausing** _(Write)_: Specifies + the maximum number of wake up packets transmitted by this site server before pausing. + This parameter is only valid on a Primary Site. +- **[UInt32] SendingWakeupPacketBeforePausingWaitSec** _(Write)_: Specifies the number + of seconds to wait between sending wake up packets to a target computer. + This parameter is only valid on a Primary Site. +- **[UInt32] ThreadNumberOfSendingWakeupPacket** _(Write)_: Specifies the number + of threads to use when sending wake up packets. + This parameter is only valid on a Primary Site. +- **[UInt32] SendingWakeupPacketTransmissionOffsetMins** _(Write)_: Specifies when + wake up packets should be sent prior to a scheduled activity. + This parameter is only valid on a Primary Site. +- **[String] ClientCertificateCustomStoreName** _(Write)_: Specifies the store + name where the client certificate is located in the Computer store when you don't + use the default store of Personal. + This parameter is only valid on a Primary Site. +- **[String] TakeActionForMultipleCertificateMatchCriteria** _(Write)_: Specifies + the action to take if multiple certificates match criteria. + This parameter is only valid on a Primary Site. + - Values include: { FailSelectionAndSendErrorMessage | + SelectCertificateWithLongestValidityPeriod } +- **[String] ClientCertificateSelectionCriteriaType** _(Write)_: Specifies the criteria + type to match in a client certificate when more than one certificate is available. + This parameter is only valid on a Primary Site. + - Values include: { ClientAuthentication | CertificateSubjectContainsString | + CertificateSubjectOrSanIncludesAttributes } +- **[String] ClientCertificateSelectionCriteriaValue** _(Write)_: Specifies a value + for the ClientCertificateSelectionCriteriaType parameter. + This parameter is only valid on a Primary Site. + +#### CMSiteConfiguration Examples + +- [CMSiteConfiguration_Cas](Source\Examples\Resources\CMSiteConfiguration\CMSiteConfiguration_Cas.ps1) +- [CMSiteConfiguration_Primary](Source\Examples\Resources\CMSiteConfiguration\CMSiteConfiguration_Primary.ps1) + ## ReverseDsc Most organizations using this module already have an existing Configuration Manager @@ -2156,6 +2263,7 @@ all of the modules and specify if it is currently supported by ReverseDSC. - DSC_CMSecurityRoles: Not Supported - DSC_CMSecurityScopes: Fully Supported - DSC_CMServiceConnectionPoint: Fully Supported +- DSC_CMSiteConfiguration: Fully Supported - DSC_CMSiteMaintenance: Fully Supported - DSC_CMSiteSystemServer: Fully Supported - DSC_CMSoftwareDistributionComponent: Fully Supported @@ -2192,7 +2300,7 @@ After importing the module, Set-ConfigMgrCBDscReverse will be available. DistributionGroups|DistributionPoint|DistributionPointGroupMembers|EmailNotificationComponent| FallbackPoints|ForestDiscovery|HeartbeatDiscovery|MaintenanceWindow|ManagementPoint| NetworkDiscovery|PullDistributionPoint|PxeDistributionPoint|GroupDiscovery| - ReportingServicesPoint|SecurityScopes|ServiceConnection|SiteMaintenance| + ReportingServicesPoint|SecurityScopes|ServiceConnection|SiteConfiguration|SiteMaintenance| SiteSystemServer|SoftwareDistributionComponent|SoftwareUpdatePoint|SoftwareupdatePointComponent| StatusReportingComponent|SystemDiscovery|UserDiscovery|ConfigFileOnly|ClientSettings| ClientSettingsBits|ClientSettingsClientCache|ClientSettingsClientPolicy|ClientSettingsCloudService| @@ -2200,7 +2308,7 @@ After importing the module, Set-ConfigMgrCBDscReverse will be available. ClientSettingsMetered|ClientSettingsPower|ClientSettingsRemoteTools|ClientSettingsSoftwareCenter| ClientSettingsSoftwareDeployment|ClientSettingsSoftwareInventory|ClientSettingsSoftwareMetering| ClientSettingsSoftwareUpdate|ClientSettingsStateMessaging| - ClientSettingsUserDeviceAffinity } + ClientSettingsUserDeviceAffinity|SiteConfiguration } - **[String] Exclude** _(Write)_: Specifies which resources will be excluded from being evaluated. Only evaluated when Include = 'All' - Values include: { Accounts|AdministrativeUser|AssetIntelligencePoint|BoundaryGroups| @@ -2208,7 +2316,7 @@ After importing the module, Set-ConfigMgrCBDscReverse will be available. DistributionGroups|DistributionPoint|DistributionPointGroupMembers|EmailNotificationComponent| FallbackPoints|ForestDiscovery|HeartbeatDiscovery|MaintenanceWindow|ManagementPoint| NetworkDiscovery|PullDistributionPoint|PxeDistributionPoint|GroupDiscovery| - ReportingServicesPoint|SecurityScopes|ServiceConnection|SiteMaintenance| + ReportingServicesPoint|SecurityScopes|ServiceConnection|SiteConfiguration|SiteMaintenance| SiteSystemServer|SoftwareDistributionComponent|SoftwareUpdatePoint|SoftwareupdatePointComponent| StatusReportingComponent|SystemDiscovery|UserDiscovery|ClientSettings| ClientSettingsBits|ClientSettingsClientCache|ClientSettingsClientPolicy|ClientSettingsCloudService| @@ -2216,7 +2324,7 @@ After importing the module, Set-ConfigMgrCBDscReverse will be available. ClientSettingsMetered|ClientSettingsPower|ClientSettingsRemoteTools|ClientSettingsSoftwareCenter| ClientSettingsSoftwareDeployment|ClientSettingsSoftwareInventory|ClientSettingsSoftwareMetering| ClientSettingsSoftwareUpdate|ClientSettingsStateMessaging| - ClientSettingsUserDeviceAffinity } + ClientSettingsUserDeviceAffinity|SiteConfiguration } - **[String] DataFile** _(Write)_: Specifies where the data file will be saved. Filename must end with .psd1. Not specifying DataFile the output will be displayed in the output screen only if Include does not equal ConfigFileOnly. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 45f4300..fd7dfd5 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -223,6 +223,8 @@ stages: env: GitHubToken: $(GitHubToken) GalleryApiToken: $(GalleryApiToken) + ReleaseBranch: master + MainGitBranch: master - task: PowerShell@2 name: sendChangelogPR displayName: 'Send Changelog PR' @@ -232,3 +234,5 @@ stages: pwsh: true env: GitHubToken: $(GitHubToken) + ReleaseBranch: master + MainGitBranch: master diff --git a/build.yaml b/build.yaml index 508feab..8f1942a 100644 --- a/build.yaml +++ b/build.yaml @@ -75,6 +75,7 @@ DscTest: - output ExcludeModuleFile: - Modules/DscResource.Common + MainGitBranch: master Resolve-Dependency: Gallery: '' diff --git a/source/ConfigMgrCBDsc.psd1 b/source/ConfigMgrCBDsc.psd1 index 490cef7..590c358 100644 --- a/source/ConfigMgrCBDsc.psd1 +++ b/source/ConfigMgrCBDsc.psd1 @@ -44,7 +44,6 @@ DscResourcesToExport = @( 'CMAccounts' 'SccmIniFile' - 'XSccmInstall' 'xSccmPreReqs' 'xSccmSqlSetup' 'CMIniFile' @@ -101,6 +100,7 @@ 'CMClientSettingsSoftwareUpdate' 'CMClientSettingsStateMessaging' 'CMClientSettingsUserDeviceAffinity' + 'CMSiteConfiguration' ) <# @@ -114,16 +114,16 @@ # Tags applied to this module. These help with module discovery in online galleries. Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource', 'ConfigMgrCBDsc','CMAccounts','SCCMPreReqs', - 'SccmSqlSetup','SCCMInstall','CMIniFile','Collections','Boundaries','ForestDiscovery','ClientStatusSettings','BoundaryGroups', - 'ManagementPoint','AssetIntelligencePoint','FallbackStatusPoint','SoftwareUpdatePoint','DistrubtionPoint','HeartbeatDiscovery', - 'ServiceConnectionPoint','NetworkDiscovery','ReportingServicePoint','SystemDiscovery','PXEDistributionPoint','PullDistributionPoint', - 'SiteMaintenance','AdministrativeUser','DistributionGroup','SiteSystemServer','StatusReportingComponent','CollectionMembershipEvaluationComponent', + 'SCCMInstall','CMIniFile','Collections','Boundaries','ForestDiscovery','ClientStatusSettings','BoundaryGroups','ManagementPoint', + 'AssetIntelligencePoint','FallbackStatusPoint','SoftwareUpdatePoint','DistrubtionPoint','HeartbeatDiscovery','ServiceConnectionPoint', + 'NetworkDiscovery','ReportingServicePoint','SystemDiscovery','PXEDistributionPoint','PullDistributionPoint','SiteMaintenance', + 'AdministrativeUser','DistributionGroup','SiteSystemServer','StatusReportingComponent','CollectionMembershipEvaluationComponent', 'DistributionPointGroupMembers','SecurityScopes','UserDiscovery','SecurityRoles','ClientPushSettings','SoftwareDistributionComponent', 'MaintenanceWindows','FileReplication','EmailNotificationComponent','CMGroupDiscovery','SoftwareUpdatePointComponent','ClientSettings', 'ClientSettingsBits','ClientSettingsClientCache','ClientSettingsClientPolicy','ClientSettingsCompliance','ClientSettingsComputerAgent', 'ClientSettingsDelivery','ClientSettingsHardware','ClientSettingsMetered','ClientSettingsPower','ClientSettingsRemoteTools', 'ClientSettingsSoftwareCenter','ClientSettingsSoftwareDeployment','ClientSettingsSoftwareInventory','ClientSettingsSoftwareMetering', - 'ClientSettingsSoftwareUpdate','ClientSettingsStateMessaging','ClientSettingsUserDeviceAffinity') + 'ClientSettingsSoftwareUpdate','ClientSettingsStateMessaging','ClientSettingsUserDeviceAffinity','SiteConfiguration') # A URL to the license for this module. LicenseUri = 'https://github.com/dsccommunity/ConfigMgrCBDsc/blob/master/LICENSE' diff --git a/source/DSCResources/DSC_CMSiteConfiguration/DSC_CMSiteConfiguration.psm1 b/source/DSCResources/DSC_CMSiteConfiguration/DSC_CMSiteConfiguration.psm1 new file mode 100644 index 0000000..6150151 --- /dev/null +++ b/source/DSCResources/DSC_CMSiteConfiguration/DSC_CMSiteConfiguration.psm1 @@ -0,0 +1,1241 @@ +$script:dscResourceCommonPath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' +$script:configMgrResourcehelper = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\ConfigMgrCBDsc.ResourceHelper' + +Import-Module -Name $script:dscResourceCommonPath +Import-Module -Name $script:configMgrResourcehelper + +$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US' + +<# + .SYNOPSIS + This will return a hashtable of results. + + .PARAMETER SiteCode + Specifies the site code for Configuration Manager site. +#> +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [Parameter(Mandatory = $true)] + [String] + $SiteCode + ) + + Write-Verbose -Message $script:localizedData.RetrieveSettingValue + Import-ConfigMgrPowerShellModule -SiteCode $SiteCode + Set-Location -Path "$($SiteCode):\" + + $senderProps = (Get-CMSiteComponent -ComponentName 'SMS_LAN_Sender' -SiteCode $SiteCode).Props + foreach ($item in $senderProps) + { + switch ($item.PropertyName) + { + 'Concurrent Sending Limit' { + $allSites = $item.Value1 + $perSite = $item.Value2 + } + 'Number of Retries' { $retry = $item.Value } + 'Retry Delay' { $retryDelay = $item.Value } + } + } + + $siteDef = Get-CMSiteDefinition -SiteCode $SiteCode + $comments = ($siteDef.Props | Where-Object -FilterScript {$_.PropertyName -eq 'Comments'}).Value1 + $defaultSize = ($siteDef.Props | Where-Object -FilterScript {$_.PropertyName -eq 'Device Collection Threshold'}).Value1 + $maxSize = ($siteDef.Props | Where-Object -FilterScript {$_.PropertyName -eq 'Device Collection Threshold'}).Value2 + + if (($siteDef.Props | Where-Object -FilterScript {$_.PropertyName -eq 'Device Collection Threshold'}).Value -eq 0) + { + $siteServerDeployment = 'Block' + } + else + { + $siteServerDeployment = 'Warn' + } + + # Communication Security + $comSec = Get-CMSiteComponent -ComponentName 'SMS_Site_Component_Manager' -SiteCode $SiteCode + $clientComms = ($comSec.Props | Where-Object -FilterScript {$_.PropertyName -eq 'IISSSLState'}).Value + + if ($clientComms -eq 0) + { + $clientCommunication = 'HttpsOrHttp' + $useCrl = $true + $pkiClient = $true + $sccmCert = $false + } + elseif ($clientComms -eq 31) + { + $clientCommunication = 'HttpsOnly' + $useCrl = $false + $pkiClient = $true + $sccmCert = $false + } + elseif ($clientComms -eq 63) + { + $clientCommunication = 'HttpsOnly' + $useCrl = $true + $pkiClient = $true + $sccmCert = $false + } + elseif ($clientComms -eq 192) + { + $clientCommunication = 'HttpsOrHttp' + $useCrl = $false + $pkiClient = $false + $sccmCert = $false + } + elseif ($clientComms -eq 224) + { + $clientCommunication = 'HttpsOrHttp' + $useCrl = $true + $pkiClient = $false + $sccmCert = $false + } + elseif ($clientComms -eq 448) + { + $clientCommunication = 'HttpsOrHttp' + $useCrl = $false + $pkiClient = $true + $sccmCert = $false + } + elseif ($clientComms -eq 480) + { + $clientCommunication = 'HttpsOrHttp' + $useCrl = $true + $pkiClient = $true + $sccmCert = $false + } + elseif ($clientComms -eq 1216) + { + $clientCommunication = 'HttpsOrHttp' + $useCrl = $false + $pkiClient = $false + $sccmCert = $true + } + elseif ($clientComms -eq 1248) + { + $clientCommunication = 'HttpsOrHttp' + $useCrl = $true + $pkiClient = $false + $sccmCert = $true + } + elseif ($clientComms -eq 1504) + { + $clientCommunication = 'HttpsOrHttp' + $useCrl = $true + $pkiClient = $true + $sccmCert = $true + } + + foreach ($item in $comSec.Props) + { + switch ($item.PropertyName) + { + 'Certificate Store' { + if ([string]::IsNullOrEmpty($item.Value1)) + { + $customStore = 'Personal' + } + else + { + $customStore = $item.Value1 + } + } + + 'Select First Certificate' { $certSel = @('FailSelectionAndSendErrorMessage','SelectCertificateWithLongestValidityPeriod')[($item.Value)] } + 'Certificate Selection Criteria' { + $criteria = $item.Value1 + if ([string]::IsNullOrEmpty($criteria)) + { + $criteriaType = 'ClientAuthentication' + $criteriaValue = '' + } + else + { + $criteriaValue = $criteria.Split(':')[1] + + if ($criteria.Split(':')[0] -eq 'SubjectStr') + { + $criteriaType = 'CertificateSubjectContainsString' + } + else + { + $criteriaType = 'CertificateSubjectOrSanIncludesAtrributes' + } + } + } + } + } + + if ($siteDef.SiteType -eq 2) + { + $sType = 'Primary' + + # Alerts + $dbAlert = (Get-CMAlert | Where-Object -FilterScript {$_.Name -eq '$DatabaseFreeSpaceWarningName'}).PropertyList.ParameterValues + if ($dbAlert) + { + $dbAlertXml = [xml]$dbAlert + $freeSpaceAlert = $true + $warningGB = $dbAlertXml.Parameters.Parameter[2].'#text' + $critGB = $dbAlertXml.Parameters.Parameter[3].'#text' + } + else + { + $freeSpaceAlert = $false + } + + [boolean]$hash = ($comSec.Props | Where-Object -FilterScript {$_.PropertyName -eq 'Enforce Enhanced Hash Algorithm'}).Value + [boolean]$signing = ($comSec.Props | Where-Object -FilterScript {$_.PropertyName -eq 'Enforce Message Signing'}).Value + + $siteSecurity = (Get-CMSiteComponent -ComponentName SMS_POLICY_PROVIDER).Props + + [boolean]$threeDes = ($siteSecurity | Where-Object -FilterScript {$_.PropertyName -eq 'Use Encryption'}).Value + + # Wake On LAN + $wol = Get-CMSiteComponent -ComponentName 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' -SiteCode $SiteCode + + if ($wol.Flag -eq 6) + { + $wolEnabled = $true + } + else + { + $wolEnabled = $false + } + + foreach ($item in $wol.Props) + { + switch ($item.PropertyName) + { + 'SendRetryMax' { $sendRetryMax = $item.Value } + 'SendRetryInterval' { $sendRetryInterval = $item.Value / 60 } + 'SendThrottleMax' { $sendThrottleMax = $item.Value } + 'SendThrottleInterval' { $sendThrottleInterval = $item.Value } + 'MaxThreads' { $maxThreads = $item.Value } + 'SendMode' { + if ($item.Value -eq 1) + { + $sendMode = 'Unicast' + } + else + { + $sendMode = 'SubnetDirectedBroadcasts' + } + } + } + } + + $wolComponent = (Get-CMSiteComponent -ComponentName 'SMS_WAKEONLAN_MANAGER' -sitecode $SiteCode).Props + $scheduleOffset = ($wolComponent | Where-Object -FilterScript {$_.PropertyName -eq 'ScheduleOffset'}).Value / 60 + } + elseif ($siteDef.SiteType -eq 4) + { + $sType = 'Cas' + $useCrl = $null + $pkiClient = $null + } + + return @{ + SiteCode = $SiteCode + Comment = $comments + MaximumConcurrentSendingForAllSite = $allSites + MaximumConcurrentSendingForPerSite = $perSite + RetryNumberForConcurrentSending = $retry + ConcurrentSendingDelayBeforeRetryingMins = $retryDelay + ThresholdOfSelectCollectionByDefault = $defaultSize + ThresholdOfSelectCollectionMax = $maxSize + SiteSystemCollectionBehavior = $siteServerDeployment + EnableLowFreeSpaceAlert = $freeSpaceAlert + FreeSpaceThresholdWarningGB = $warningGB + FreeSpaceThresholdCriticalGB = $critGB + ClientComputerCommunicationType = $clientCommunication + ClientCheckCertificateRevocationListForSiteSystem = $useCrl + UsePkiClientCertificate = $pkiClient + UseSmsGeneratedCert = $sccmCert + RequireSha256 = $hash + RequireSigning = $signing + UseEncryption = $threeDes + SiteType = $sType + EnableWakeOnLan = $wolEnabled + WakeOnLanTransmissionMethodType = $sendMode + RetryNumberOfSendingWakeupPacketTransmission = $sendRetryMax + SendingWakeupPacketTransmissionDelayMins = $sendRetryInterval + MaximumNumberOfSendingWakeupPacketBeforePausing = $sendThrottleMax + SendingWakeupPacketBeforePausingWaitSec = $sendThrottleInterval + ThreadNumberOfSendingWakeupPacket = $maxThreads + SendingWakeupPacketTransmissionOffsetMins = $scheduleOffset + ClientCertificateCustomStoreName = $customStore + TakeActionForMultipleCertificateMatchCriteria = $certSel + ClientCertificateSelectionCriteriaType = $criteriaType + ClientCertificateSelectionCriteriaValue = $criteriaValue + } +} + +<# + .SYNOPSIS + This will set the desired state. + + .PARAMETER SiteCode + Specifies a site code for the Configuration Manager site. + + .Parameter Comment + Specifies the site comments. + + .PARAMETER ClientComputerCommunicationType + Specifies the communication method for the site systems that use IIS. To use HTTPS, + the servers need a valid PKI web server certificate for server authentication. + + This parameter is only valid on a Primary Site. + + .PARAMETER ClientCheckCertificateRevocationListForSiteSystem + Indicates whether clients check the Certificate Revocation List (CRL) for site systems. + + This parameter is only valid on a Primary Site. + + .PARAMETER UsePkiClientCertificate + Indicates whether to use a PKI client certificate for client authentication when available. + + This parameter is only valid on a Primary Site. + + .PARAMETER UseSmsGeneratedCert + Use this parameter to enable or disable the site property to Use Configuration Manager-generated + certificates for HTTP site systems. + + This parameter is only valid on a Primary Site. + + .PARAMETER RequireSigning + This option requires that clients sign data when they send to management points. + + This parameter is only valid on a Primary Site. + + .PARAMETER RequireSha256 + Specifies if the clients sign data and communicate with site systems by using HTTP, this option requires the + clients to use SHA-256 to sign the data. This option applies to clients that don't use PKI certificates. + + This parameter is only valid on a Primary Site. + + .PARAMETER UseEncryption + Specifies to use 3DES to encrypt the client inventory data and state messages that are sent to the + management point. + + This parameter is only valid on a Primary Site. + + .PARAMETER MaximumConcurrentSendingForAllSite + Specifies the maximum number of simultaneous communications to all sites. + + .PARAMETER MaximumConcurrentSendingForPerSite + Specifies the maximum number of simultaneous communications to any single site. + + .PARAMETER RetryNumberForConcurrentSending + Specifies the number of times to retry a failed communication. + + .PARAMETER ConcurrentSendingDelayBeforeRetryingMins + Specifies the number of minutes to delay before it retries. + + .PARAMETER EnableLowFreeSpaceAlert + Specifies if an alert is created when the free disk space on the site database server is low. + + This parameter is only valid on a Primary Site. + + .PARAMETER FreeSpaceThresholdWarningGB + Specifies disk space warning alert when the free disk space on the + site database server falls below the specified threshold. + + This parameter is only valid on a Primary Site. + + .PARAMETER FreeSpaceThresholdCriticalGB + Specifies disk space critical alert when the free disk space on the + site database server falls below the specified threshold. + + This parameter is only valid on a Primary Site. + + .PARAMETER ThresholdOfSelectCollectionByDefault + Specifies select collection window hides collections with membership that + exceeds this value. + + .PARAMETER ThresholdOfSelectCollectionMax + Specifies select collection window always hides collections that have more members + than this maximum value. + + .PARAMETER SiteSystemCollectionBehavior + Specifies the behavior to take when the selected collection includes computers that + host site systems roles. + + .PARAMETER EnableWakeOnLan + Indicates whether to send Wake On LAN packets for scheduled activities such as deployments + of software updates. + + This parameter is only valid on a Primary Site. + + .PARAMETER WakeOnLanTransmissionMethodType + Specifies the type of transmission method to use for Wake On LAN transmissions. + + This parameter is only valid on a Primary Site. + + .PARAMETER RetryNumberOfSendingWakeupPacketTransmission + Specifies the number of times a wake up packet is sent to a target computer. + + This parameter is only valid on a Primary Site. + + .PARAMETER SendingWakeupPacketTransmissionDelayMins + Specifies the number of minutes to delay between wake up retries. + + This parameter is only valid on a Primary Site. + + .PARAMETER MaximumNumberOfSendingWakeupPacketBeforePausing + Specifies the maximum number of wake up packets transmitted by this site server before pausing. + + This parameter is only valid on a Primary Site. + + .PARAMETER SendingWakeupPacketBeforePausingWaitSec + Specifies the number of seconds to wait between sending wake up packets to a target computer. + + This parameter is only valid on a Primary Site. + + .PARAMETER ThreadNumberOfSendingWakeupPacket + Specifies the number of threads to use when sending wake up packets. + + This parameter is only valid on a Primary Site. + + .PARAMETER SendingWakeupPacketTransmissionOffsetMins + Specifies when wake up packets should be sent prior to a scheduled activity. + + This parameter is only valid on a Primary Site. + + .PARAMETER ClientCertificateCustomStoreName + Specifies the store name where the client certificate is located in the Computer store when + you don't use the default store of Personal. + + This parameter is only valid on a Primary Site. + + .PARAMETER TakeActionForMultipleCertificateMatchCriteria + Specifies the action to take if multiple certificates match criteria. + + This parameter is only valid on a Primary Site. + + .PARAMETER ClientCertificateSelectionCriteriaType + Specifies the criteria type to match in a client certificate when more than one + certificate is available. + + This parameter is only valid on a Primary Site. + + .PARAMETER ClientCertificateSelectionCriteriaValue + Specifies a value for the ClientCertificateSelectionCriteriaType parameter. + + This parameter is only valid on a Primary Site. +#> +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [String] + $SiteCode, + + [Parameter()] + [String] + $Comment, + + [Parameter()] + [ValidateSet('HttpsOnly','HttpsOrHttp')] + [String] + $ClientComputerCommunicationType, + + [Parameter()] + [Boolean] + $ClientCheckCertificateRevocationListForSiteSystem, + + [Parameter()] + [Boolean] + $UsePkiClientCertificate, + + [Parameter()] + [Boolean] + $UseSmsGeneratedCert, + + [Parameter()] + [Boolean] + $RequireSigning, + + [Parameter()] + [Boolean] + $RequireSha256, + + [Parameter()] + [Boolean] + $UseEncryption, + + [Parameter()] + [ValidateRange(1,999)] + [UInt32] + $MaximumConcurrentSendingForAllSite, + + [Parameter()] + [ValidateRange(1,999)] + [UInt32] + $MaximumConcurrentSendingForPerSite, + + [Parameter()] + [ValidateRange(1,99)] + [UInt32] + $RetryNumberForConcurrentSending, + + [Parameter()] + [ValidateRange(1,99)] + [UInt32] + $ConcurrentSendingDelayBeforeRetryingMins, + + [Parameter()] + [Boolean] + $EnableLowFreeSpaceAlert, + + [Parameter()] + [ValidateRange(1,32767)] + [UInt32] + $FreeSpaceThresholdWarningGB, + + [Parameter()] + [ValidateRange(1,32767)] + [UInt32] + $FreeSpaceThresholdCriticalGB, + + [Parameter()] + [ValidateRange(0,1000000)] + [UInt32] + $ThresholdOfSelectCollectionByDefault, + + [Parameter()] + [ValidateRange(0,1000000)] + [UInt32] + $ThresholdOfSelectCollectionMax, + + [Parameter()] + [ValidateSet('Warn','Block')] + [String] + $SiteSystemCollectionBehavior, + + [Parameter()] + [Boolean] + $EnableWakeOnLan, + + [Parameter()] + [ValidateSet('Unicast','SubnetDirectedBroadcasts')] + [String] + $WakeOnLanTransmissionMethodType, + + [Parameter()] + [ValidateRange(1,5)] + [UInt32] + $RetryNumberOfSendingWakeupPacketTransmission, + + [Parameter()] + [ValidateRange(1,5)] + [UInt32] + $SendingWakeupPacketTransmissionDelayMins, + + [Parameter()] + [ValidateRange(1000,300000)] + [UInt32] + $MaximumNumberOfSendingWakeupPacketBeforePausing, + + [Parameter()] + [ValidateRange(0,100)] + [UInt32] + $SendingWakeupPacketBeforePausingWaitSec, + + [Parameter()] + [ValidateRange(1,9)] + [UInt32] + $ThreadNumberOfSendingWakeupPacket, + + [Parameter()] + [ValidateRange(0,60)] + [UInt32] + $SendingWakeupPacketTransmissionOffsetMins, + + [Parameter()] + [String] + $ClientCertificateCustomStoreName, + + [Parameter()] + [ValidateSet('FailSelectionAndSendErrorMessage','SelectCertificateWithLongestValidityPeriod')] + [String] + $TakeActionForMultipleCertificateMatchCriteria, + + [Parameter()] + [ValidateSet('ClientAuthentication','CertificateSubjectContainsString','CertificateSubjectOrSanIncludesAttributes')] + [String] + $ClientCertificateSelectionCriteriaType, + + [Parameter()] + [String] + $ClientCertificateSelectionCriteriaValue + ) + + Import-ConfigMgrPowerShellModule -SiteCode $SiteCode + Set-Location -Path "$($SiteCode):\" + $state = Get-TargetResource -SiteCode $SiteCode + + try + { + $defaultValues = @( + 'SiteCode','Comment','MaximumConcurrentSendingForAllSite','MaximumConcurrentSendingForPerSite', + 'RetryNumberForConcurrentSending','ConcurrentSendingDelayBeforeRetryingMins','ThresholdOfSelectCollectionByDefault', + 'ThresholdOfSelectCollectionMax','SiteSystemCollectionBehavior' + ) + + if ($PSBoundParameters.ContainsKey('ThresholdOfSelectCollectionByDefault') -or $PSBoundParameters.ContainsKey('ThresholdOfSelectCollectionMax')) + { + if ($PSBoundParameters.ContainsKey('ThresholdOfSelectCollectionByDefault')) + { + $collectionDefault = $ThresholdOfSelectCollectionByDefault + } + elseif ($state.ThresholdOfSelectCollectionByDefault) + { + $collectionDefault = $state.ThresholdOfSelectCollectionByDefault + } + + if ($PSBoundParameters.ContainsKey('ThresholdOfSelectCollectionMax')) + { + $collectionMax = $ThresholdOfSelectCollectionMax + } + elseif ($state.ThresholdOfSelectCollectionMax) + { + $collectionMax = $state.ThresholdOfSelectCollectionMax + } + + if (($collectionMax -ne 0) -and ($collectionMax -le $collectionDefault)) + { + throw ($script:localizedData.CollectionError -f $collectionDefault, $collectionMax) + } + } + + if ($state.SiteType -eq 'Primary') + { + $defaultValues += @( + 'ClientCheckCertificateRevocationListForSiteSystem','UsePkiClientCertificate','RequireSigning','UseEncryption', + 'EnableLowFreeSpaceAlert','EnableWakeOnLan','ClientCertificateCustomStoreName','TakeActionForMultipleCertificateMatchCriteria', + 'ClientCertificateSelectionCriteriaType','ClientComputerCommunicationType' + ) + + if (($PSBoundParameters.ContainsKey('UseSmsGeneratedCert')) -and + (-not [string]::IsNullOrEmpty($ClientComputerCommunicationType) -and $ClientComputerCommunicationType -eq 'HttpsOnly') -or + ([string]::IsNullOrEmpty($ClientComputerCommunicationType) -and $state.ClientComputerCommunicationType -eq 'HttpsOnly')) + { + Write-Warning -Message $script:localizedData.IgnoreSMSCert + } + else + { + $defaultValues += @('UseSmsGeneratedCert') + } + + if ($PSBoundParameters.ContainsKey('EnableLowFreeSpaceAlert') -or $PSBoundParameters.ContainsKey('FreeSpaceThresholdWarningGB') -or + $PSBoundParameters.ContainsKey('FreeSpaceThresholdCriticalGB')) + { + if ($EnableLowFreeSpaceAlert -eq $true) + { + if (-not $PSBoundParameters.ContainsKey('FreeSpaceThresholdWarningGB') -or + -not $PSBoundParameters.ContainsKey('FreeSpaceThresholdCriticalGB')) + { + throw $script:localizedData.AlertMissing + } + else + { + if ($FreeSpaceThresholdCriticalGB -ge $FreeSpaceThresholdWarningGB) + { + throw $script:localizedData.AlertErrorMsg + } + else + { + $defaultValues += @('FreeSpaceThresholdWarningGB','FreeSpaceThresholdCriticalGB') + } + } + } + else + { + if ($PSBoundParameters.ContainsKey('FreeSpaceThresholdWarningGB') -or + $PSBoundParameters.ContainsKey('FreeSpaceThresholdCriticalGB')) + { + Write-Warning -Message $script:localizedData.IgnoreAlertsSettings + } + } + } + + $wolParams = @( + 'WakeOnLanTransmissionMethodType','RetryNumberOfSendingWakeupPacketTransmission','SendingWakeupPacketTransmissionDelayMins', + 'MaximumNumberOfSendingWakeupPacketBeforePausing','SendingWakeupPacketBeforePausingWaitSec','ThreadNumberOfSendingWakeupPacket', + 'SendingWakeupPacketTransmissionOffsetMins' + ) + + foreach ($param in $wolParams) + { + if (($EnableWakeOnLan -eq $false) -or ($State.EnableWakeOnLan -eq $false -and (-not $PSBoundParameters.ContainsKey('EnableWakeOnLan'))) -and + ($PSBoundParameters.ContainsKey($param))) + { + Write-Warning -Message ($script:localizedData.WakeFalse -f $param) + } + else + { + $defaultValues += $param + } + } + + if ($PSBoundParameters.ContainsKey('ClientCertificateSelectionCriteriaType')) + { + if ($ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + if ($PSBoundParameters.ContainsKey('ClientCertificateSelectionCriteriaValue')) + { + Write-Warning -Message $script:localizedData.IgnoreCertValue + } + } + else + { + if (-not $PSBoundParameters.ContainsKey('ClientCertificateSelectionCriteriaValue')) + { + throw ($script:localizedData.MissingCertValue -f $ClientCertificateSelectionCriteriaType) + } + else + { + $defaultValues += @('ClientCertificateSelectionCriteriaValue') + } + } + } + elseif ($PSBoundParameters.ContainsKey('ClientCertificateSelectionCriteriaValue')) + { + throw $script:localizedData.MissingCertType + } + + if ($PSBoundParameters.ContainsKey('ClientCertificateCustomStoreName') -and [string]::IsNullOrEmpty($ClientCertificateCustomStoreName)) + { + $PSBoundParameters.ClientCertificateCustomStoreName = 'Personal' + Write-Warning -Message $script:localizedData.NullCertStore + } + } + elseif ($state.SiteType -eq 'Cas') + { + foreach ($param in $PSBoundParameters.GetEnumerator()) + { + if (($defaultValues -notcontains $param.Key) -and ($param.Key -ne 'verbose')) + { + Write-Warning -Message ($script:localizedData.IgnorePrimarySetting -f $param.Key) + } + } + } + + foreach ($param in $PSBoundParameters.GetEnumerator()) + { + if ($defaultValues -contains $param.Key) + { + if ($param.Value -ne $state[$param.Key]) + { + Write-Verbose -Message ($script:localizedData.SettingValue -f $param.Key, $param.Value) + $buildingParams += @{ + $param.Key = $param.Value + } + } + } + } + + if ($buildingParams) + { + Set-CMSite -SiteCode $SiteCode @buildingParams + } + } + catch + { + throw $_ + } + finally + { + Set-Location -Path "$env:temp" + } +} + +<# + .SYNOPSIS + This will set the desired state. + + .PARAMETER SiteCode + Specifies a site code for the Configuration Manager site. + + .Parameter Comment + Specifies the site comments. + + .PARAMETER ClientComputerCommunicationType + Specifies the communication method for the site systems that use IIS. To use HTTPS, + the servers need a valid PKI web server certificate for server authentication. + + This parameter is only valid on a Primary Site. + + .PARAMETER ClientCheckCertificateRevocationListForSiteSystem + Indicates whether clients check the Certificate Revocation List (CRL) for site systems. + + This parameter is only valid on a Primary Site. + + .PARAMETER UsePkiClientCertificate + Indicates whether to use a PKI client certificate for client authentication when available. + + This parameter is only valid on a Primary Site. + + .PARAMETER UseSmsGeneratedCert + Use this parameter to enable or disable the site property to Use Configuration Manager-generated + certificates for HTTP site systems. + + This parameter is only valid on a Primary Site. + + .PARAMETER RequireSigning + This option requires that clients sign data when they send to management points. + + This parameter is only valid on a Primary Site. + + .PARAMETER RequireSha256 + Specifies if the clients sign data and communicate with site systems by using HTTP, this option requires the + clients to use SHA-256 to sign the data. This option applies to clients that don't use PKI certificates. + + This parameter is only valid on a Primary Site. + + .PARAMETER UseEncryption + Specifies to use 3DES to encrypt the client inventory data and state messages that are sent to the + management point. + + This parameter is only valid on a Primary Site. + + .PARAMETER MaximumConcurrentSendingForAllSite + Specifies the maximum number of simultaneous communications to all sites. + + .PARAMETER MaximumConcurrentSendingForPerSite + Specifies the maximum number of simultaneous communications to any single site. + + .PARAMETER RetryNumberForConcurrentSending + Specifies the number of times to retry a failed communication. + + .PARAMETER ConcurrentSendingDelayBeforeRetryingMins + Specifies the number of minutes to delay before it retries. + + .PARAMETER EnableLowFreeSpaceAlert + Specifies if an alert is created when the free disk space on the site database server is low. + + This parameter is only valid on a Primary Site. + + .PARAMETER FreeSpaceThresholdWarningGB + Specifies disk space warning alert when the free disk space on the + site database server falls below the specified threshold. + + This parameter is only valid on a Primary Site. + + .PARAMETER FreeSpaceThresholdCriticalGB + Specifies disk space critical alert when the free disk space on the + site database server falls below the specified threshold. + + This parameter is only valid on a Primary Site. + + .PARAMETER ThresholdOfSelectCollectionByDefault + Specifies select collection window hides collections with membership that + exceeds this value. + + .PARAMETER ThresholdOfSelectCollectionMax + Specifies select collection window always hides collections that have more members + than this maximum value. + + .PARAMETER SiteSystemCollectionBehavior + Specifies the behavior to take when the selected collection includes computers that + host site systems roles. + + .PARAMETER EnableWakeOnLan + Indicates whether to send Wake On LAN packets for scheduled activities such as deployments + of software updates. + + This parameter is only valid on a Primary Site. + + .PARAMETER WakeOnLanTransmissionMethodType + Specifies the type of transmission method to use for Wake On LAN transmissions. + + This parameter is only valid on a Primary Site. + + .PARAMETER RetryNumberOfSendingWakeupPacketTransmission + Specifies the number of times a wake up packet is sent to a target computer. + + This parameter is only valid on a Primary Site. + + .PARAMETER SendingWakeupPacketTransmissionDelayMins + Specifies the number of minutes to delay between wake up retries. + + This parameter is only valid on a Primary Site. + + .PARAMETER MaximumNumberOfSendingWakeupPacketBeforePausing + Specifies the maximum number of wake up packets transmitted by this site server before pausing. + + This parameter is only valid on a Primary Site. + + .PARAMETER SendingWakeupPacketBeforePausingWaitSec + Specifies the number of seconds to wait between sending wake up packets to a target computer. + + This parameter is only valid on a Primary Site. + + .PARAMETER ThreadNumberOfSendingWakeupPacket + Specifies the number of threads to use when sending wake up packets. + + This parameter is only valid on a Primary Site. + + .PARAMETER SendingWakeupPacketTransmissionOffsetMins + Specifies when wake up packets should be sent prior to a scheduled activity. + + This parameter is only valid on a Primary Site. + + .PARAMETER ClientCertificateCustomStoreName + Specifies the store name where the client certificate is located in the Computer store when + you don't use the default store of Personal. + + This parameter is only valid on a Primary Site. + + .PARAMETER TakeActionForMultipleCertificateMatchCriteria + Specifies the action to take if multiple certificates match criteria. + + This parameter is only valid on a Primary Site. + + .PARAMETER ClientCertificateSelectionCriteriaType + Specifies the criteria type to match in a client certificate when more than one + certificate is available. + + This parameter is only valid on a Primary Site. + + .PARAMETER ClientCertificateSelectionCriteriaValue + Specifies a value for the ClientCertificateSelectionCriteriaType parameter. + + This parameter is only valid on a Primary Site. +#> +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [Parameter(Mandatory = $true)] + [String] + $SiteCode, + + [Parameter()] + [String] + $Comment, + + [Parameter()] + [ValidateSet('HttpsOnly','HttpsOrHttp')] + [String] + $ClientComputerCommunicationType, + + [Parameter()] + [Boolean] + $ClientCheckCertificateRevocationListForSiteSystem, + + [Parameter()] + [Boolean] + $UsePkiClientCertificate, + + [Parameter()] + [Boolean] + $UseSmsGeneratedCert, + + [Parameter()] + [Boolean] + $RequireSigning, + + [Parameter()] + [Boolean] + $RequireSha256, + + [Parameter()] + [Boolean] + $UseEncryption, + + [Parameter()] + [ValidateRange(1,999)] + [UInt32] + $MaximumConcurrentSendingForAllSite, + + [Parameter()] + [ValidateRange(1,999)] + [UInt32] + $MaximumConcurrentSendingForPerSite, + + [Parameter()] + [ValidateRange(1,99)] + [UInt32] + $RetryNumberForConcurrentSending, + + [Parameter()] + [ValidateRange(1,99)] + [UInt32] + $ConcurrentSendingDelayBeforeRetryingMins, + + [Parameter()] + [Boolean] + $EnableLowFreeSpaceAlert, + + [Parameter()] + [ValidateRange(1,32767)] + [UInt32] + $FreeSpaceThresholdWarningGB, + + [Parameter()] + [ValidateRange(1,32767)] + [UInt32] + $FreeSpaceThresholdCriticalGB, + + [Parameter()] + [ValidateRange(0,1000000)] + [UInt32] + $ThresholdOfSelectCollectionByDefault, + + [Parameter()] + [ValidateRange(0,1000000)] + [UInt32] + $ThresholdOfSelectCollectionMax, + + [Parameter()] + [ValidateSet('Warn','Block')] + [String] + $SiteSystemCollectionBehavior, + + [Parameter()] + [Boolean] + $EnableWakeOnLan, + + [Parameter()] + [ValidateSet('Unicast','SubnetDirectedBroadcasts')] + [String] + $WakeOnLanTransmissionMethodType, + + [Parameter()] + [ValidateRange(1,5)] + [UInt32] + $RetryNumberOfSendingWakeupPacketTransmission, + + [Parameter()] + [ValidateRange(1,5)] + [UInt32] + $SendingWakeupPacketTransmissionDelayMins, + + [Parameter()] + [ValidateRange(1000,300000)] + [UInt32] + $MaximumNumberOfSendingWakeupPacketBeforePausing, + + [Parameter()] + [ValidateRange(0,100)] + [UInt32] + $SendingWakeupPacketBeforePausingWaitSec, + + [Parameter()] + [ValidateRange(1,9)] + [UInt32] + $ThreadNumberOfSendingWakeupPacket, + + [Parameter()] + [ValidateRange(0,60)] + [UInt32] + $SendingWakeupPacketTransmissionOffsetMins, + + [Parameter()] + [String] + $ClientCertificateCustomStoreName, + + [Parameter()] + [ValidateSet('FailSelectionAndSendErrorMessage','SelectCertificateWithLongestValidityPeriod')] + [String] + $TakeActionForMultipleCertificateMatchCriteria, + + [Parameter()] + [ValidateSet('ClientAuthentication','CertificateSubjectContainsString','CertificateSubjectOrSanIncludesAttributes')] + [String] + $ClientCertificateSelectionCriteriaType, + + [Parameter()] + [String] + $ClientCertificateSelectionCriteriaValue + ) + + Import-ConfigMgrPowerShellModule -SiteCode $SiteCode + Set-Location -Path "$($SiteCode):\" + $state = Get-TargetResource -SiteCode $SiteCode + $result = $true + $badInput = $false + + $defaultValues = @( + 'SiteCode','Comment','MaximumConcurrentSendingForAllSite','MaximumConcurrentSendingForPerSite', + 'RetryNumberForConcurrentSending','ConcurrentSendingDelayBeforeRetryingMins','ThresholdOfSelectCollectionByDefault', + 'ThresholdOfSelectCollectionMax','SiteSystemCollectionBehavior' + ) + + if ($PSBoundParameters.ContainsKey('ThresholdOfSelectCollectionByDefault') -or $PSBoundParameters.ContainsKey('ThresholdOfSelectCollectionMax')) + { + if ($PSBoundParameters.ContainsKey('ThresholdOfSelectCollectionByDefault')) + { + $collectionDefault = $ThresholdOfSelectCollectionByDefault + } + elseif ($state.ThresholdOfSelectCollectionByDefault) + { + $collectionDefault = $state.ThresholdOfSelectCollectionByDefault + } + + if ($PSBoundParameters.ContainsKey('ThresholdOfSelectCollectionMax')) + { + $collectionMax = $ThresholdOfSelectCollectionMax + } + elseif ($state.ThresholdOfSelectCollectionMax) + { + $collectionMax = $state.ThresholdOfSelectCollectionMax + } + + if (($collectionMax -ne 0) -and ($collectionMax -le $collectionDefault)) + { + Write-Warning -Message ($script:localizedData.CollectionError -f $collectionDefault, $collectionMax) + } + } + + if ($state.SiteType -eq 'Primary') + { + $defaultValues += @( + 'ClientCheckCertificateRevocationListForSiteSystem','UsePkiClientCertificate','RequireSigning','UseEncryption', + 'EnableLowFreeSpaceAlert','EnableWakeOnLan','ClientCertificateCustomStoreName','TakeActionForMultipleCertificateMatchCriteria', + 'ClientCertificateSelectionCriteriaType','ClientComputerCommunicationType' + ) + + if (($PSBoundParameters.ContainsKey('UseSmsGeneratedCert')) -and + (-not [string]::IsNullOrEmpty($ClientComputerCommunicationType) -and $ClientComputerCommunicationType -eq 'HttpsOnly') -or + ([string]::IsNullOrEmpty($ClientComputerCommunicationType) -and $state.ClientComputerCommunicationType -eq 'HttpsOnly')) + { + Write-Warning -Message $script:localizedData.IgnoreSMSCert + } + else + { + $defaultValues += @('UseSmsGeneratedCert') + } + + if ($PSBoundParameters.ContainsKey('EnableLowFreeSpaceAlert') -or $PSBoundParameters.ContainsKey('FreeSpaceThresholdWarningGB') -or + $PSBoundParameters.ContainsKey('FreeSpaceThresholdCriticalGB')) + { + if ($EnableLowFreeSpaceAlert -eq $true) + { + if (-not $PSBoundParameters.ContainsKey('FreeSpaceThresholdWarningGB') -or + -not $PSBoundParameters.ContainsKey('FreeSpaceThresholdCriticalGB')) + { + Write-Warning -Message $script:localizedData.AlertMissing + $badInput = $true + } + else + { + if ($FreeSpaceThresholdCriticalGB -ge $FreeSpaceThresholdWarningGB) + { + Write-Warning -Message $script:localizedData.AlertErrorMsg + $badInput = $true + } + else + { + $defaultValues += @('FreeSpaceThresholdWarningGB','FreeSpaceThresholdCriticalGB') + } + } + } + else + { + if ($PSBoundParameters.ContainsKey('FreeSpaceThresholdWarningGB') -or + $PSBoundParameters.ContainsKey('FreeSpaceThresholdCriticalGB')) + { + Write-Warning -Message $script:localizedData.IgnoreAlertsSettings + } + } + } + + $wolParams = @( + 'WakeOnLanTransmissionMethodType','RetryNumberOfSendingWakeupPacketTransmission','SendingWakeupPacketTransmissionDelayMins', + 'MaximumNumberOfSendingWakeupPacketBeforePausing','SendingWakeupPacketBeforePausingWaitSec','ThreadNumberOfSendingWakeupPacket', + 'SendingWakeupPacketTransmissionOffsetMins' + ) + + foreach ($param in $wolParams) + { + if (($EnableWakeOnLan -eq $false) -or ($State.EnableWakeOnLan -eq $false -and (-not $PSBoundParameters.ContainsKey('EnableWakeOnLan'))) -and + ($PSBoundParameters.ContainsKey($param))) + { + Write-Warning -Message ($script:localizedData.WakeFalse -f $param) + } + else + { + $defaultValues += $param + } + } + + if ($PSBoundParameters.ContainsKey('ClientCertificateSelectionCriteriaType')) + { + if ($ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + if ($PSBoundParameters.ContainsKey('ClientCertificateSelectionCriteriaValue')) + { + Write-Warning -Message $script:localizedData.IgnoreCertValue + } + } + else + { + if (-not $PSBoundParameters.ContainsKey('ClientCertificateSelectionCriteriaValue')) + { + Write-Warning -Message ($script:localizedData.MissingCertValue -f $ClientCertificateSelectionCriteriaType) + $badInput = $true + } + else + { + $defaultValues += @('ClientCertificateSelectionCriteriaValue') + } + } + } + elseif ($PSBoundParameters.ContainsKey('ClientCertificateSelectionCriteriaValue')) + { + Write-Warning -Message $script:localizedData.MissingCertType + $badInput = $true + } + + if ($PSBoundParameters.ContainsKey('ClientCertificateCustomStoreName') -and [string]::IsNullOrEmpty($ClientCertificateCustomStoreName)) + { + $PSBoundParameters.ClientCertificateCustomStoreName = 'Personal' + Write-Warning -Message $script:localizedData.NullCertStore + } + } + elseif ($state.SiteType -eq 'Cas') + { + foreach ($param in $PSBoundParameters.GetEnumerator()) + { + if (($defaultValues -notcontains $param.Key) -and ($param.Key -ne 'verbose')) + { + Write-Warning -Message ($script:localizedData.IgnorePrimarySetting -f $param.Key) + } + } + } + + $testParams = @{ + CurrentValues = $state + DesiredValues = $PSBoundParameters + ValuesToCheck = $defaultValues + } + + $testResult = Test-DscParameterState @testParams -TurnOffTypeChecking -Verbose + + if ($testResult -eq $true -and $badInput -eq $false) + { + $result = $true + } + else + { + $result = $false + } + + Write-Verbose -Message ($script:localizedData.TestState -f $result) + Set-Location -Path "$env:temp" + return $result +} + +Export-ModuleMember -Function *-TargetResource diff --git a/source/DSCResources/DSC_CMSiteConfiguration/DSC_CMSiteConfiguration.schema.mof b/source/DSCResources/DSC_CMSiteConfiguration/DSC_CMSiteConfiguration.schema.mof new file mode 100644 index 0000000..8810a60 --- /dev/null +++ b/source/DSCResources/DSC_CMSiteConfiguration/DSC_CMSiteConfiguration.schema.mof @@ -0,0 +1,36 @@ +[ClassVersion("1.0.0"), FriendlyName("CMSiteConfiguration")] +class DSC_CMSiteConfiguration: OMI_BaseResource +{ + [Key, Description("Specifies the SiteCode for the Configuration Manager site.")] String SiteCode; + [Write, Description("Specifies the site comment.")] String Comment; + [Write, Description("Specifies the communication method for the site systems that use IIS. To use HTTPS, the servers need a valid PKI web server certificate for server authentication."), ValueMap{"HttpsOnly","HttpsOrHttp"}, Values{"HttpsOnly","HttpsOrHttp"}] String ClientComputerCommunicationType; + [Write, Description("Indicates whether clients check the Certificate Revocation List (CRL) for site systems.")] Boolean ClientCheckCertificateRevocationListForSiteSystem; + [Write, Description("Indicates whether to use a PKI client certificate for client authentication when available.")] Boolean UsePkiClientCertificate; + [Write, Description("Use this parameter to enable or disable the site property to Use Configuration Manager-generated certificates for HTTP site systems.")] Boolean UseSmsGeneratedCert; + [Write, Description("This option requires that clients sign data when they send to management points.")] Boolean RequireSigning; + [Write, Description("Specifies if the clients sign data and communicate with site systems by using HTTP, this option requires the clients to use SHA-256 to sign the data. This option applies to clients that don't use PKI certificates.")] Boolean RequireSha256; + [Write, Description("Specifies to use 3DES to encrypt the client inventory data and state messages that are sent to the management point.")] Boolean UseEncryption; + [Write, Description("Specifies the maximum number of simultaneous communications to all sites.")] UInt32 MaximumConcurrentSendingForAllSite; + [Write, Description("Specifies the maximum number of simultaneous communications to any single site.")] UInt32 MaximumConcurrentSendingForPerSite; + [Write, Description("Specifies the number of times to retry a failed communication.")] UInt32 RetryNumberForConcurrentSending; + [Write, Description("Specifies the number of minutes to delay before it retries.")] UInt32 ConcurrentSendingDelayBeforeRetryingMins; + [Write, Description("Specifies if an alert is created when the free disk space on the site database server is low.")] Boolean EnableLowFreeSpaceAlert; + [Write, Description("Specifies disk space warning alert when the free disk space on the site database server falls below the specified threshold.")] UInt32 FreeSpaceThresholdWarningGB; + [Write, Description("Specifies disk space critical alert when the free disk space on the site database server falls below the specified threshold.")] UInt32 FreeSpaceThresholdCriticalGB; + [Write, Description("Specifies select collection window hides collections with membership that exceeds this value.")] UInt32 ThresholdOfSelectCollectionByDefault; + [Write, Description("Specifies select collection window always hides collections that have more members than this maximum value.")] UInt32 ThresholdOfSelectCollectionMax; + [Write, Description("Specifies the behavior to take when the selected collection includes computers that host site systems roles."), ValueMap{"Warn","Block"}, Values{"Warn","Block"}] String SiteSystemCollectionBehavior; + [Write, Description("Indicates whether to send Wake On LAN packets for scheduled activities such as deployments of software updates.")] Boolean EnableWakeOnLan; + [Write, Description("Specifies the type of transmission method to use for Wake On LAN transmissions."), ValueMap{"Unicast","SubnetDirectedBroadcasts"}, Values{"Unicast","SubnetDirectedBroadcasts"}] String WakeOnLanTransmissionMethodType; + [Write, Description("Specifies the number of times a wake up packet is sent to a target computer.")] UInt32 RetryNumberOfSendingWakeupPacketTransmission; + [Write, Description("Specifies the number of minutes to delay between wake up retries.")] UInt32 SendingWakeupPacketTransmissionDelayMins; + [Write, Description("Specifies the maximum number of wake up packets transmitted by this site server before pausing.")] UInt32 MaximumNumberOfSendingWakeupPacketBeforePausing; + [Write, Description("Specifies the number of seconds to wait between sending wake up packets to a target computer.")] UInt32 SendingWakeupPacketBeforePausingWaitSec; + [Write, Description("Specifies the number of threads to use when sending wake up packets.")] UInt32 ThreadNumberOfSendingWakeupPacket; + [Write, Description("Specifies when wake up packets should be sent prior to a scheduled activity.")] UInt32 SendingWakeupPacketTransmissionOffsetMins; + [Write, Description("Specifies the store name where the client certificate is located in the Computer store when you don't use the default store of Personal.")] String ClientCertificateCustomStoreName; + [Write, Description("Specifies the action to take if multiple certificates match criteria."), ValueMap{"FailSelectionAndSendErrorMessage","SelectCertificateWithLongestValidityPeriod"}, Values{"FailSelectionAndSendErrorMessage","SelectCertificateWithLongestValidityPeriod"}] String TakeActionForMultipleCertificateMatchCriteria; + [Write, Description("Specifies the criteria type to match in a client certificate when more than one certificate is available."), ValueMap{"ClientAuthentication","CertificateSubjectContainsString","CertificateSubjectOrSanIncludesAttributes"}, Values{"ClientAuthentication","CertificateSubjectContainsString","CertificateSubjectOrSanIncludesAttributes"}] String ClientCertificateSelectionCriteriaType; + [Write, Description("Specifies a value for the ClientCertificateSelectionCriteriaType parameter.")] String ClientCertificateSelectionCriteriaValue; + [Read, Description("Specifies the site type, CAS or Primary")] String SiteType; +}; diff --git a/source/DSCResources/DSC_CMSiteConfiguration/en-US/DSC_CMSiteConfiguration.strings.psd1 b/source/DSCResources/DSC_CMSiteConfiguration/en-US/DSC_CMSiteConfiguration.strings.psd1 new file mode 100644 index 0000000..97fd9c8 --- /dev/null +++ b/source/DSCResources/DSC_CMSiteConfiguration/en-US/DSC_CMSiteConfiguration.strings.psd1 @@ -0,0 +1,16 @@ +ConvertFrom-StringData @' + RetrieveSettingValue = Getting information for the specified Fallback Status Point. + IgnoreSMSCert = When specifying HttpsOnly, UseSMSGeneratedCert can not be specified, ignoring setting. + IgnorePrimarySetting = Current site type is CAS, {0} does not apply to a CAS server. + IgnoreAlertsSettings = EnableLowFreeSpaceAlert is disabled and FreeSpaceThreshold Warning or Critical GB was specified, ignoring settings. + CollectionError = ThresholdOfSelectCollectionByDefault of: {0} must be less than ThresholdOfSelectCollectionMax: {1}. + AlertMissing = When setting EnableLowFreeSpaceAlert to true, FreeSpaceThreshold warning and critical must be specified. + AlertErrorMsg = FreeSpaceThresholdCritical is greater than or equal to FreeSpaceThresholdWarning. Warning should be greater than Critical. + TestState = Test-TargetResource compliance check returned: {0}. + SettingValue = Setting value: {0} to {1}. + WakeFalse = When EnableWakeOnLan is disabled the {0} parameter will be ignored. + IgnoreCertValue = When ClientCertificateSelectionCriteriaType is set to ClientAuthentication, the ClientCertificateSelectionCriteriaValue is ignored. + MissingCertValue = When ClientCertificateSelectionCriteriaType is specified as {0}, ClientCertificateSelectionCriteriaValue is required. + MissingCertType = When ClientCertificateSelectionCriteriaValue is specified, ClientCertificateSelectionCriteriaType is required. + NullCertStore = ClientCertificateCustomStoreName cannot be specified as empty. The default value of Personal will be used. +'@ diff --git a/source/Examples/Resources/CMSiteConfiguration/CMSiteConfiguration_Cas.ps1 b/source/Examples/Resources/CMSiteConfiguration/CMSiteConfiguration_Cas.ps1 new file mode 100644 index 0000000..c15d08f --- /dev/null +++ b/source/Examples/Resources/CMSiteConfiguration/CMSiteConfiguration_Cas.ps1 @@ -0,0 +1,24 @@ +<# + .SYNOPSIS + A DSC configuration to configure Site Configurations in Configuration Manager. +#> +Configuration Example +{ + Import-DscResource -ModuleName ConfigMgrCBDsc + + Node localhost + { + CMSiteConfiguration ExampleConfig + { + SiteCode = 'Lab' + Comment = 'Lab Site CAS' + MaximumConcurrentSendingForAllSite = 5 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 10 + ConcurrentSendingDelayBeforeRetryingMins = 5 + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 0 + SiteSystemCollectionBehavior = 'Block' + } + } +} diff --git a/source/Examples/Resources/CMSiteConfiguration/CMSiteConfiguration_Primary.ps1 b/source/Examples/Resources/CMSiteConfiguration/CMSiteConfiguration_Primary.ps1 new file mode 100644 index 0000000..13ba097 --- /dev/null +++ b/source/Examples/Resources/CMSiteConfiguration/CMSiteConfiguration_Primary.ps1 @@ -0,0 +1,45 @@ +<# + .SYNOPSIS + A DSC configuration to configure Site Configurations in Configuration Manager. +#> +Configuration Example +{ + Import-DscResource -ModuleName ConfigMgrCBDsc + + Node localhost + { + CMSiteConfiguration ExampleConfig + { + SiteCode = 'PRI' + Comment = 'Lab Site Primary' + MaximumConcurrentSendingForAllSite = 5 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 10 + ConcurrentSendingDelayBeforeRetryingMins = 5 + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 0 + SiteSystemCollectionBehavior = 'Block' + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 10 + FreeSpaceThresholdCriticalGB = 5 + ClientComputerCommunicationType = 'HttpsOrHttp' + ClientCheckCertificateRevocationListForSiteSystem = $true + UsePkiClientCertificate = $true + UseSmsGeneratedCert = $true + RequireSha256 = $true + RequireSigning = $true + UseEncryption = $true + EnableWakeOnLan = $true + WakeOnLanTransmissionMethodType = 'Unicast' + RetryNumberOfSendingWakeupPacketTransmission = 3 + SendingWakeupPacketTransmissionDelayMins = 1 + MaximumNumberOfSendingWakeupPacketBeforePausing = 10000 + SendingWakeupPacketBeforePausingWaitSec = 10 + ThreadNumberOfSendingWakeupPacket = 3 + SendingWakeupPacketTransmissionOffsetMins = 0 + ClientCertificateCustomStoreName = 'Personal' + TakeActionForMultipleCertificateMatchCriteria = 'SelectCertificateWithLongestValidityPeriod' + ClientCertificateSelectionCriteriaType = 'ClientAuthentication' + } + } +} diff --git a/source/Modules/ConfigMgrCBDsc.ReverseDsc/ConfigMgrCBDsc.ReverseDsc.psm1 b/source/Modules/ConfigMgrCBDsc.ReverseDsc/ConfigMgrCBDsc.ReverseDsc.psm1 index d42c6cb..5c8e480 100644 --- a/source/Modules/ConfigMgrCBDsc.ReverseDsc/ConfigMgrCBDsc.ReverseDsc.psm1 +++ b/source/Modules/ConfigMgrCBDsc.ReverseDsc/ConfigMgrCBDsc.ReverseDsc.psm1 @@ -292,7 +292,7 @@ function Set-OutFile if ($ResourceName -eq 'CMPullDistributionPoint') { - $sourceDP = 'SourceDistirbutionPoint' + $sourceDP = 'SourceDistributionPoint' $tester += "`t`t$($sourceDP.PadRight($updatedCount)) = @(`r`n" foreach ($item in $cPush.SourceDistributionPoint) @@ -645,6 +645,10 @@ Configuration ConfigureSccm [HashTable] `$CMServiceConnectionPoint, + [Parameter()] + [HashTable] + `$CMSiteConfiguration, + [Parameter()] [HashTable[]] `$CMSiteMaintenance, @@ -3685,6 +3689,554 @@ Configuration ConfigureSccm } } + if (`$CMSiteConfiguration) + { + if (`$CMSiteConfiguration.EnableWakeOnLan -eq `$null) + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + } + } + else + { + if (`$CMSiteConfiguration.EnableWakeOnLan -eq `$false) + { + if(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOnly' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$true -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + FreeSpaceThresholdWarningGB = `$CMSiteConfiguration.FreeSpaceThresholdWarningGB + FreeSpaceThresholdCriticalGB = `$CMSiteConfiguration.FreeSpaceThresholdCriticalGB + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOnly' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$true -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -ne 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + FreeSpaceThresholdWarningGB = `$CMSiteConfiguration.FreeSpaceThresholdWarningGB + FreeSpaceThresholdCriticalGB = `$CMSiteConfiguration.FreeSpaceThresholdCriticalGB + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + ClientCertificateSelectionCriteriaValue = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaValue + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOnly' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$false -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOnly' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$false -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -ne 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + ClientCertificateSelectionCriteriaValue = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaValue + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOrHttp' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$true -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + FreeSpaceThresholdWarningGB = `$CMSiteConfiguration.FreeSpaceThresholdWarningGB + FreeSpaceThresholdCriticalGB = `$CMSiteConfiguration.FreeSpaceThresholdCriticalGB + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + UseSmsGeneratedCert = `$CMSiteConfiguration.UseSmsGeneratedCert + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOrHttp' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$true -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -ne 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + FreeSpaceThresholdWarningGB = `$CMSiteConfiguration.FreeSpaceThresholdWarningGB + FreeSpaceThresholdCriticalGB = `$CMSiteConfiguration.FreeSpaceThresholdCriticalGB + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + UseSmsGeneratedCert = `$CMSiteConfiguration.UseSmsGeneratedCert + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + ClientCertificateSelectionCriteriaValue = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaValue + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOrHttp' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$false -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + UseSmsGeneratedCert = `$CMSiteConfiguration.UseSmsGeneratedCert + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOrHttp' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$false -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -ne 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + UseSmsGeneratedCert = `$CMSiteConfiguration.UseSmsGeneratedCert + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + ClientCertificateSelectionCriteriaValue = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaValue + } + } + } + else + { + if(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOnly' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$true -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + FreeSpaceThresholdWarningGB = `$CMSiteConfiguration.FreeSpaceThresholdWarningGB + FreeSpaceThresholdCriticalGB = `$CMSiteConfiguration.FreeSpaceThresholdCriticalGB + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + WakeOnLanTransmissionMethodType = `$CMSiteConfiguration.WakeOnLanTransmissionMethodType + RetryNumberOfSendingWakeupPacketTransmission = `$CMSiteConfiguration.RetryNumberOfSendingWakeupPacketTransmission + SendingWakeupPacketTransmissionDelayMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionDelayMins + MaximumNumberOfSendingWakeupPacketBeforePausing = `$CMSiteConfiguration.MaximumNumberOfSendingWakeupPacketBeforePausing + SendingWakeupPacketBeforePausingWaitSec = `$CMSiteConfiguration.SendingWakeupPacketBeforePausingWaitSec + ThreadNumberOfSendingWakeupPacket = `$CMSiteConfiguration.ThreadNumberOfSendingWakeupPacket + SendingWakeupPacketTransmissionOffsetMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionOffsetMins + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOnly' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$true -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -ne 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + FreeSpaceThresholdWarningGB = `$CMSiteConfiguration.FreeSpaceThresholdWarningGB + FreeSpaceThresholdCriticalGB = `$CMSiteConfiguration.FreeSpaceThresholdCriticalGB + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + WakeOnLanTransmissionMethodType = `$CMSiteConfiguration.WakeOnLanTransmissionMethodType + RetryNumberOfSendingWakeupPacketTransmission = `$CMSiteConfiguration.RetryNumberOfSendingWakeupPacketTransmission + SendingWakeupPacketTransmissionDelayMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionDelayMins + MaximumNumberOfSendingWakeupPacketBeforePausing = `$CMSiteConfiguration.MaximumNumberOfSendingWakeupPacketBeforePausing + SendingWakeupPacketBeforePausingWaitSec = `$CMSiteConfiguration.SendingWakeupPacketBeforePausingWaitSec + ThreadNumberOfSendingWakeupPacket = `$CMSiteConfiguration.ThreadNumberOfSendingWakeupPacket + SendingWakeupPacketTransmissionOffsetMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionOffsetMins + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + ClientCertificateSelectionCriteriaValue = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaValue + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOnly' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$false -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + WakeOnLanTransmissionMethodType = `$CMSiteConfiguration.WakeOnLanTransmissionMethodType + RetryNumberOfSendingWakeupPacketTransmission = `$CMSiteConfiguration.RetryNumberOfSendingWakeupPacketTransmission + SendingWakeupPacketTransmissionDelayMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionDelayMins + MaximumNumberOfSendingWakeupPacketBeforePausing = `$CMSiteConfiguration.MaximumNumberOfSendingWakeupPacketBeforePausing + SendingWakeupPacketBeforePausingWaitSec = `$CMSiteConfiguration.SendingWakeupPacketBeforePausingWaitSec + ThreadNumberOfSendingWakeupPacket = `$CMSiteConfiguration.ThreadNumberOfSendingWakeupPacket + SendingWakeupPacketTransmissionOffsetMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionOffsetMins + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOnly' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$false -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -ne 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + WakeOnLanTransmissionMethodType = `$CMSiteConfiguration.WakeOnLanTransmissionMethodType + RetryNumberOfSendingWakeupPacketTransmission = `$CMSiteConfiguration.RetryNumberOfSendingWakeupPacketTransmission + SendingWakeupPacketTransmissionDelayMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionDelayMins + MaximumNumberOfSendingWakeupPacketBeforePausing = `$CMSiteConfiguration.MaximumNumberOfSendingWakeupPacketBeforePausing + SendingWakeupPacketBeforePausingWaitSec = `$CMSiteConfiguration.SendingWakeupPacketBeforePausingWaitSec + ThreadNumberOfSendingWakeupPacket = `$CMSiteConfiguration.ThreadNumberOfSendingWakeupPacket + SendingWakeupPacketTransmissionOffsetMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionOffsetMins + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + ClientCertificateSelectionCriteriaValue = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaValue + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOrHttp' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$true -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + FreeSpaceThresholdWarningGB = `$CMSiteConfiguration.FreeSpaceThresholdWarningGB + FreeSpaceThresholdCriticalGB = `$CMSiteConfiguration.FreeSpaceThresholdCriticalGB + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + UseSmsGeneratedCert = `$CMSiteConfiguration.UseSmsGeneratedCert + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + WakeOnLanTransmissionMethodType = `$CMSiteConfiguration.WakeOnLanTransmissionMethodType + RetryNumberOfSendingWakeupPacketTransmission = `$CMSiteConfiguration.RetryNumberOfSendingWakeupPacketTransmission + SendingWakeupPacketTransmissionDelayMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionDelayMins + MaximumNumberOfSendingWakeupPacketBeforePausing = `$CMSiteConfiguration.MaximumNumberOfSendingWakeupPacketBeforePausing + SendingWakeupPacketBeforePausingWaitSec = `$CMSiteConfiguration.SendingWakeupPacketBeforePausingWaitSec + ThreadNumberOfSendingWakeupPacket = `$CMSiteConfiguration.ThreadNumberOfSendingWakeupPacket + SendingWakeupPacketTransmissionOffsetMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionOffsetMins + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOrHttp' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$true -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -ne 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + FreeSpaceThresholdWarningGB = `$CMSiteConfiguration.FreeSpaceThresholdWarningGB + FreeSpaceThresholdCriticalGB = `$CMSiteConfiguration.FreeSpaceThresholdCriticalGB + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + UseSmsGeneratedCert = `$CMSiteConfiguration.UseSmsGeneratedCert + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + WakeOnLanTransmissionMethodType = `$CMSiteConfiguration.WakeOnLanTransmissionMethodType + RetryNumberOfSendingWakeupPacketTransmission = `$CMSiteConfiguration.RetryNumberOfSendingWakeupPacketTransmission + SendingWakeupPacketTransmissionDelayMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionDelayMins + MaximumNumberOfSendingWakeupPacketBeforePausing = `$CMSiteConfiguration.MaximumNumberOfSendingWakeupPacketBeforePausing + SendingWakeupPacketBeforePausingWaitSec = `$CMSiteConfiguration.SendingWakeupPacketBeforePausingWaitSec + ThreadNumberOfSendingWakeupPacket = `$CMSiteConfiguration.ThreadNumberOfSendingWakeupPacket + SendingWakeupPacketTransmissionOffsetMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionOffsetMins + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + ClientCertificateSelectionCriteriaValue = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaValue + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOrHttp' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$false -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -eq 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + UseSmsGeneratedCert = `$CMSiteConfiguration.UseSmsGeneratedCert + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + WakeOnLanTransmissionMethodType = `$CMSiteConfiguration.WakeOnLanTransmissionMethodType + RetryNumberOfSendingWakeupPacketTransmission = `$CMSiteConfiguration.RetryNumberOfSendingWakeupPacketTransmission + SendingWakeupPacketTransmissionDelayMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionDelayMins + MaximumNumberOfSendingWakeupPacketBeforePausing = `$CMSiteConfiguration.MaximumNumberOfSendingWakeupPacketBeforePausing + SendingWakeupPacketBeforePausingWaitSec = `$CMSiteConfiguration.SendingWakeupPacketBeforePausingWaitSec + ThreadNumberOfSendingWakeupPacket = `$CMSiteConfiguration.ThreadNumberOfSendingWakeupPacket + SendingWakeupPacketTransmissionOffsetMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionOffsetMins + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + } + } + elseif(`$CMSiteConfiguration.ClientComputerCommunicationType -eq 'HttpsOrHttp' -and `$CMSiteConfiguration.EnableLowFreeSpaceAlert -eq `$false -and + `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType -ne 'ClientAuthentication') + { + CMSiteConfiguration CMSiteConfiguration + { + SiteCode = `$SiteCode + Comment = `$CMSiteConfiguration.Comment + MaximumConcurrentSendingForAllSite = `$CMSiteConfiguration.MaximumConcurrentSendingForAllSite + MaximumConcurrentSendingForPerSite = `$CMSiteConfiguration.MaximumConcurrentSendingForPerSite + RetryNumberForConcurrentSending = `$CMSiteConfiguration.RetryNumberForConcurrentSending + ConcurrentSendingDelayBeforeRetryingMins = `$CMSiteConfiguration.ConcurrentSendingDelayBeforeRetryingMins + ThresholdOfSelectCollectionByDefault = `$CMSiteConfiguration.ThresholdOfSelectCollectionByDefault + ThresholdOfSelectCollectionMax = `$CMSiteConfiguration.ThresholdOfSelectCollectionMax + SiteSystemCollectionBehavior = `$CMSiteConfiguration.SiteSystemCollectionBehavior + EnableLowFreeSpaceAlert = `$CMSiteConfiguration.EnableLowFreeSpaceAlert + ClientComputerCommunicationType = `$CMSiteConfiguration.ClientComputerCommunicationType + ClientCheckCertificateRevocationListForSiteSystem = `$CMSiteConfiguration.ClientCheckCertificateRevocationListForSiteSystem + UsePkiClientCertificate = `$CMSiteConfiguration.UsePkiClientCertificate + UseSmsGeneratedCert = `$CMSiteConfiguration.UseSmsGeneratedCert + RequireSha256 = `$CMSiteConfiguration.RequireSha256 + RequireSigning = `$CMSiteConfiguration.RequireSigning + UseEncryption = `$CMSiteConfiguration.UseEncryption + EnableWakeOnLan = `$CMSiteConfiguration.EnableWakeOnLan + WakeOnLanTransmissionMethodType = `$CMSiteConfiguration.WakeOnLanTransmissionMethodType + RetryNumberOfSendingWakeupPacketTransmission = `$CMSiteConfiguration.RetryNumberOfSendingWakeupPacketTransmission + SendingWakeupPacketTransmissionDelayMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionDelayMins + MaximumNumberOfSendingWakeupPacketBeforePausing = `$CMSiteConfiguration.MaximumNumberOfSendingWakeupPacketBeforePausing + SendingWakeupPacketBeforePausingWaitSec = `$CMSiteConfiguration.SendingWakeupPacketBeforePausingWaitSec + ThreadNumberOfSendingWakeupPacket = `$CMSiteConfiguration.ThreadNumberOfSendingWakeupPacket + SendingWakeupPacketTransmissionOffsetMins = `$CMSiteConfiguration.SendingWakeupPacketTransmissionOffsetMins + ClientCertificateCustomStoreName = `$CMSiteConfiguration.ClientCertificateCustomStoreName + TakeActionForMultipleCertificateMatchCriteria = `$CMSiteConfiguration.TakeActionForMultipleCertificateMatchCriteria + ClientCertificateSelectionCriteriaType = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaType + ClientCertificateSelectionCriteriaValue = `$CMSiteConfiguration.ClientCertificateSelectionCriteriaValue + } + } + } + } + } + if (`$CMSiteSystemServer) { foreach (`$item in `$CMSiteSystemServer) @@ -4286,7 +4838,7 @@ Configuration ConfigureSccm foreach (`$pull in `$CMPullDistributionPoint) { `$pullRankings = @() - foreach (`$value in `$pull.SourceDP) + foreach (`$value in `$pull.SourceDistributionPoint) { `$pullRankings += DSC_CMPullDistributionPointSourceDP { @@ -10618,7 +11170,7 @@ function Set-ConfigMgrCBDscReverse 'ClientSettingsHardware','ClientSettingsMetered','ClientSettingsPower', 'ClientSettingsRemoteTools','ClientSettingsSoftwareCenter','ClientSettingsSoftwareDeployment', 'ClientSettingsSoftwareInventory','ClientSettingsSoftwareMetering','ClientSettingsSoftwareUpdate', - 'ClientSettingsStateMessaging','ClientSettingsUserDeviceAffinity')] + 'ClientSettingsStateMessaging','ClientSettingsUserDeviceAffinity','SiteConfiguration')] [String[]] $Include = 'All', @@ -10637,7 +11189,7 @@ function Set-ConfigMgrCBDscReverse 'ClientSettingsHardware','ClientSettingsMetered','ClientSettingsPower', 'ClientSettingsRemoteTools','ClientSettingsSoftwareCenter','ClientSettingsSoftwareDeployment', 'ClientSettingsSoftwareInventory','ClientSettingsSoftwareMetering','ClientSettingsSoftwareUpdate', - 'ClientSettingsStateMessaging','ClientSettingsUserDeviceAffinity')] + 'ClientSettingsStateMessaging','ClientSettingsUserDeviceAffinity','SiteConfiguration')] [String[]] $Exclude, @@ -12181,6 +12733,38 @@ function Set-ConfigMgrCBDscReverse } } + if (($Include -eq 'All' -and $Exclude -notcontains 'SiteConfiguration') -or ($Include -contains 'SiteConfiguration')) + { + $resourceName = 'CMSiteConfiguration' + Write-Verbose -Message ($script:localizedData.SingleOutput -f $resourceName) -Verbose + $wSiteConfiguration = "$resourceName = @{`r`n" + $siteType = Get-CMSiteDefinition -SiteCode $SiteCode + + if ($siteType.SiteType -eq 2) + { + $excluded = @('SiteCode','SiteType') + } + else + { + $excluded = @('SiteCode','ClientCheckCertificateRevocationListForSiteSystem', 'ClientComputerCommunicationType' + 'UsePkiClientCertificate', 'RequireSigning','UseEncryption','EnableLowFreeSpaceAlert', + 'FreeSpaceThresholdCriticalGB','FreeSpaceThresholdWarningGB','SiteType','UseSmsGeneratedCert') + } + + $params = @{ + ResourceName = $resourceName + SiteCode = $SiteCode + Indent = 1 + MultiEntry = $false + Resources = $resources + ExcludeList = $excluded + } + + $testThing = Set-OutFile @params + $wSiteConfiguration += "$testThing" + $fileOut += "$wSiteConfiguration`r`n" + } + if (($Include -eq 'All' -and $Exclude -notcontains 'SiteMaintenance') -or ($Include -contains 'SiteMaintenance')) { $resourceName = 'CMSiteMaintenance' diff --git a/tests/Unit/CMSiteConfiguration.tests.ps1 b/tests/Unit/CMSiteConfiguration.tests.ps1 new file mode 100644 index 0000000..42dd739 --- /dev/null +++ b/tests/Unit/CMSiteConfiguration.tests.ps1 @@ -0,0 +1,1591 @@ +param () + +$script:dscModuleName = 'ConfigMgrCBDsc' +$script:dscResourceName = 'DSC_CMSiteConfiguration' + +function Invoke-TestSetup +{ + try + { + Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' + } + catch [System.IO.FileNotFoundException] + { + throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' + } + + $script:testEnvironment = Initialize-TestEnvironment ` + -DSCModuleName $script:dscModuleName ` + -DSCResourceName $script:dscResourceName ` + -ResourceType 'Mof' ` + -TestType 'Unit' + + # Import Stub function + $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath 'Stubs\ConfigMgrCBDscStub.psm1') -Force -WarningAction SilentlyContinue +} + +function Invoke-TestCleanup +{ + Restore-TestEnvironment -TestEnvironment $script:testEnvironment +} + +Invoke-TestSetup + +#Begin Testing +try +{ + InModuleScope $script:dscResourceName { + Describe 'ConfigMgrCBDsc - DSC_CMSiteConfiguration\Get-TargetResource' -Tag 'Get' { + BeforeAll { + $getInput = @{ + SiteCode = 'Lab' + } + + $getLanSenderReturn = @{ + Props = @( + @{ + PropertyName = 'Concurrent Sending Limit' + Value = 0 + Value1 = 6 + Value2 = 3 + } + @{ + PropertyName = 'Number of Retries' + Value = 3 + } + @{ + PropertyName = 'Retry Delay' + Value = 2 + } + ) + } + + $getSiteDefBlockReturn = @{ + SiteType = 2 + Props = @( + @{ + PropertyName = 'Comments' + Value1 = 'Site Lab' + } + @{ + PropertyName = 'Device Collection Threshold' + Value = 0 + Value1 = 100 + Value2 = 200 + } + @{ + PropertyName = 'Retry Delay' + Value = 2 + } + ) + } + + $getSiteDefWarnReturn = @{ + SiteType = 2 + Props = @( + @{ + PropertyName = 'Comments' + Value1 = 'Site Lab' + } + @{ + PropertyName = 'Device Collection Threshold' + Value = 1 + Value1 = 100 + Value2 = 200 + } + @{ + PropertyName = 'Retry Delay' + Value = 2 + } + ) + } + + $getSiteDefCas = @{ + SiteType = 4 + Props = @( + @{ + PropertyName = 'Comments' + Value1 = 'Site Lab' + } + @{ + PropertyName = 'Device Collection Threshold' + Value = 1 + Value1 = 100 + Value2 = 200 + } + @{ + PropertyName = 'Retry Delay' + Value = 2 + } + ) + } + + $getSiteCompManager0Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 0 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + ) + } + + $getSiteCompManager31Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 31 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = 'SMSStore' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = '' + } + ) + } + + $getSiteCompManager63Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 63 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = 'SMSStore' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = 'SubjectStr:Test' + } + ) + } + + $getSiteCompManager192Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 192 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = 'SMSStore' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = 'SubjectAttr:Test' + } + ) + } + + $getSiteCompManager224Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 224 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = 'SMSStore' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = 'SubjectAttr:Test' + } + ) + } + + $getSiteCompManager448Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 448 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = 'SMSStore' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = 'SubjectAttr:Test' + } + ) + } + + $getSiteCompManager480Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 480 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = 'SMSStore' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = 'SubjectAttr:Test' + } + ) + } + + $getSiteCompManager1216Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 1216 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = 'SMSStore' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = 'SubjectAttr:Test' + } + ) + } + + $getSiteCompManager1248Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 1248 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = 'SMSStore' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = 'SubjectAttr:Test' + } + ) + } + + $getSiteCompManager1504Return = @{ + Props = @( + @{ + PropertyName = 'IISSSLState' + Value = 1504 + } + @{ + PropertyName = 'Enforce Enhanced Hash Algorithm' + Value = 1 + } + @{ + PropertyName = 'Enforce Message Signing' + Value = 1 + } + @{ + PropertyName = 'Certificate Store' + Value1 = '' + } + @{ + PropertyName = 'Select First Certificate' + Value = 0 + } + @{ + PropertyName = 'Certificate Selection Criteria' + Value1 = 'SubjectAttr:Test' + } + ) + } + + $getCMAlertEnabled = @( + @{ + Name = '$DatabaseFreeSpaceWarningName' + PropertyList = @{ + ParameterValues = @( + '51' + ) + } + } + ) + + $getPolicyProvider = @{ + Props = @( + @{ + PropertyName = 'Use Encryption' + Value = 1 + } + ) + } + + $wolDisabled = @{ + Flag = 1 + } + + $wolUnicast = @{ + Flag = 6 + Props = @( + @{ + PropertyName = 'SendRetryMax' + Value = 3 + } + @{ + PropertyName = 'SendRetryInterval' + Value = 60 + } + @{ + PropertyName = 'SendThrottleMax' + Value = 10000 + } + @{ + PropertyName = 'SendThrottleInterval' + Value = 10 + } + @{ + PropertyName = 'MaxThreads' + Value = 3 + } + @{ + PropertyName = 'SendMode' + Value = 1 + } + ) + } + + $wolBroadcast = @{ + Flag = 6 + Props = @( + @{ + PropertyName = 'SendRetryMax' + Value = 3 + } + @{ + PropertyName = 'SendRetryInterval' + Value = 60 + } + @{ + PropertyName = 'SendThrottleMax' + Value = 10000 + } + @{ + PropertyName = 'SendThrottleInterval' + Value = 10 + } + @{ + PropertyName = 'MaxThreads' + Value = 3 + } + @{ + PropertyName = 'SendMode' + Value = 2 + } + ) + } + + $wolComponent = @{ + Props = @( + @{ + PropertyName = 'ScheduleOffset' + Value = 600 + } + ) + } + + Mock -CommandName Get-CMSiteComponent -MockWith { $getLanSenderReturn } -ParameterFilter {$ComponentName -match 'SMS_LAN_Sender'} + Mock -CommandName Get-CMSiteComponent -MockWith { $getPolicyProvider } -ParameterFilter {$ComponentName -match 'SMS_POLICY_PROVIDER'} + Mock -CommandName Import-ConfigMgrPowerShellModule + Mock -CommandName Set-Location + } + + Context 'When retrieving Site Configuration settings' { + + It 'Should return desired result when site configuration settings are HTTPS\HTTP only for CAS' { + Mock -CommandName Get-CMAlert + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefCas } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager0Return } -ParameterFilter {$ComponentName -match 'SMS_Site_Component_Manager'} + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOrHttp' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $null + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $null + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $false + $result.RequireSigning | Should -Be -ExpectedValue $null + $result.RequireSha256 | Should -Be -ExpectedValue $null + $result.UseEncryption | Should -Be -ExpectedValue $null + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $null + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue $null + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue $null + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'CAS' + } + + It 'Should return desired result when site configuration settings are HTTPS Only and blocked Primary' { + Mock -CommandName Get-CMAlert -MockWith { $null } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefBlockReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager31Return } -ParameterFilter {$ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolDisabled } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $null } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOnly' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $false + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $true + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $false + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $false + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue $null + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue $null + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Block' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $false + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue $null + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue $null + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue $null + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue $null + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue $null + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue $null + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 0 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'SMSStore' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'ClientAuthentication' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue '' + } + + It 'Should return desired result when site configuration settings are HTTPS Only with CRL and warn' { + Mock -CommandName Get-CMAlert -MockWith { $getCMAlertEnabled } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefWarnReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager63Return } -ParameterFilter { $ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolBroadcast } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolComponent } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOnly' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $true + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $true + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $false + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $true + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue 5 + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue 1 + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $true + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue 'SubnetDirectedBroadcasts' + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue 1 + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue 10000 + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue 10 + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 10 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'SMSStore' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'CertificateSubjectContainsString' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue 'Test' + } + + It 'Should return desired result when site configuration settings are HTTPS\HTTP only' { + Mock -CommandName Get-CMAlert -MockWith { $getCMAlertEnabled } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefWarnReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager192Return } -ParameterFilter { $ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolUnicast } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolComponent } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOrHttp' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $false + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $false + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $false + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $true + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue 5 + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue 1 + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $true + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue 'Unicast' + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue 1 + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue 10000 + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue 10 + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 10 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'SMSStore' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'CertificateSubjectOrSanIncludesAtrributes' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue 'Test' + } + + It 'Should return desired result when site configuration settings are HTTPS\HTTP and CRL' { + Mock -CommandName Get-CMAlert -MockWith { $getCMAlertEnabled } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefWarnReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager224Return } -ParameterFilter { $ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolUnicast } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolComponent } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOrHttp' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $true + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $false + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $false + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $true + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue 5 + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue 1 + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $true + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue 'Unicast' + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue 1 + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue 10000 + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue 10 + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 10 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'SMSStore' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'CertificateSubjectOrSanIncludesAtrributes' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue 'Test' + } + + It 'Should return desired result when site configuration settings are HTTPS\HTTP and PKI' { + Mock -CommandName Get-CMAlert -MockWith { $getCMAlertEnabled } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefWarnReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager448Return } -ParameterFilter { $ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolUnicast } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolComponent } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOrHttp' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $false + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $true + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $false + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $true + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue 5 + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue 1 + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $true + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue 'Unicast' + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue 1 + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue 10000 + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue 10 + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 10 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'SMSStore' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'CertificateSubjectOrSanIncludesAtrributes' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue 'Test' + } + + It 'Should return desired result when site configuration settings are HTTPS\HTTP and PKI and CRL' { + Mock -CommandName Get-CMAlert -MockWith { $getCMAlertEnabled } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefWarnReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager480Return } -ParameterFilter { $ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolUnicast } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolComponent } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOrHttp' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $true + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $true + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $false + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $true + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue 5 + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue 1 + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $true + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue 'Unicast' + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue 1 + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue 10000 + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue 10 + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 10 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'SMSStore' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'CertificateSubjectOrSanIncludesAtrributes' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue 'Test' + } + + It 'Should return desired result when site configuration settings are HTTPS\HTTP and SCCM Cert' { + Mock -CommandName Get-CMAlert -MockWith { $getCMAlertEnabled } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefWarnReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager1216Return } -ParameterFilter { $ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolUnicast } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolComponent } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOrHttp' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $false + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $false + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $true + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $true + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue 5 + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue 1 + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $true + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue 'Unicast' + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue 1 + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue 10000 + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue 10 + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 10 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'SMSStore' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'CertificateSubjectOrSanIncludesAtrributes' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue 'Test' + } + + It 'Should return desired result when site configuration settings are HTTPS\HTTP and SCCM Cert and CRL' { + Mock -CommandName Get-CMAlert -MockWith { $getCMAlertEnabled } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefWarnReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager1248Return } -ParameterFilter { $ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolUnicast } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolComponent } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOrHttp' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $true + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $false + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $true + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $true + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue 5 + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue 1 + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $true + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue 'Unicast' + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue 1 + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue 10000 + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue 10 + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 10 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'SMSStore' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'CertificateSubjectOrSanIncludesAtrributes' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue 'Test' + } + + It 'Should return desired result when site configuration settings are HTTPS\HTTP and SCCM Cert and PKI and CRL' { + Mock -CommandName Get-CMAlert -MockWith { $getCMAlertEnabled } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getSiteDefWarnReturn } + Mock -CommandName Get-CMSiteComponent -MockWith { $getSiteCompManager1504Return } -ParameterFilter { $ComponentName -match 'SMS_Site_Component_Manager' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolUnicast } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_COMMUNICATION_MANAGER' } + Mock -CommandName Get-CMSiteComponent -MockWith { $wolComponent } -ParameterFilter { $ComponentName -match 'SMS_WAKEONLAN_MANAGER' } + + $result = Get-TargetResource @getInput + $result | Should -BeOfType System.Collections.HashTable + $result.SiteCode | Should -Be -ExpectedValue 'Lab' + $result.Comment | Should -Be -ExpectedValue 'Site Lab' + $result.ClientComputerCommunicationType | Should -Be -ExpectedValue 'HttpsOrHttp' + $result.ClientCheckCertificateRevocationListForSiteSystem | Should -Be -ExpectedValue $true + $result.UsePkiClientCertificate | Should -Be -ExpectedValue $true + $result.UseSmsGeneratedCert | Should -Be -ExpectedValue $true + $result.RequireSigning | Should -Be -ExpectedValue $true + $result.RequireSha256 | Should -Be -ExpectedValue $true + $result.UseEncryption | Should -Be -ExpectedValue $true + $result.MaximumConcurrentSendingForAllSite | Should -Be -ExpectedValue 6 + $result.MaximumConcurrentSendingForPerSite | Should -Be -ExpectedValue 3 + $result.RetryNumberForConcurrentSending | Should -Be -ExpectedValue 3 + $result.ConcurrentSendingDelayBeforeRetryingMins | Should -Be -ExpectedValue 2 + $result.EnableLowFreeSpaceAlert | Should -Be -ExpectedValue $true + $result.FreeSpaceThresholdWarningGB | Should -Be -ExpectedValue 5 + $result.FreeSpaceThresholdCriticalGB | Should -Be -ExpectedValue 1 + $result.ThresholdOfSelectCollectionByDefault | Should -Be -ExpectedValue 100 + $result.ThresholdOfSelectCollectionMax | Should -Be -ExpectedValue 200 + $result.SiteSystemCollectionBehavior | Should -Be -ExpectedValue 'Warn' + $result.SiteType | Should -Be -ExpectedValue 'Primary' + $result.EnableWakeOnLan | Should -Be -ExpectedValue $true + $result.WakeOnLanTransmissionMethodType | Should -Be -ExpectedValue 'Unicast' + $result.RetryNumberOfSendingWakeupPacketTransmission | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionDelayMins | Should -Be -ExpectedValue 1 + $result.MaximumNumberOfSendingWakeupPacketBeforePausing | Should -Be -ExpectedValue 10000 + $result.SendingWakeupPacketBeforePausingWaitSec | Should -Be -ExpectedValue 10 + $result.ThreadNumberOfSendingWakeupPacket | Should -Be -ExpectedValue 3 + $result.SendingWakeupPacketTransmissionOffsetMins | Should -Be -ExpectedValue 10 + $result.ClientCertificateCustomStoreName | Should -Be -ExpectedValue 'Personal' + $result.TakeActionForMultipleCertificateMatchCriteria | Should -Be -ExpectedValue 'FailSelectionAndSendErrorMessage' + $result.ClientCertificateSelectionCriteriaType | Should -Be -ExpectedValue 'CertificateSubjectOrSanIncludesAtrributes' + $result.ClientCertificateSelectionCriteriaValue | Should -Be -ExpectedValue 'Test' + } + } + } + + Describe 'ConfigMgrCBDsc - DSC_CMSiteConfiguration\Set-TargetResource' -Tag 'Set' { + BeforeAll { + $getReturnAll = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + ClientComputerCommunicationType = 'HttpsOrHttp' + ClientCheckCertificateRevocationListForSiteSystem = $true + UsePkiClientCertificate = $false + UseSmsGeneratedCert = $true + RequireSigning = $true + RequireSha256 = $false + UseEncryption = $false + MaximumConcurrentSendingForAllSite = 6 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 2 + ConcurrentSendingDelayBeforeRetryingMins = 10 + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 10 + FreeSpaceThresholdCriticalGB = 5 + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 1000 + SiteSystemCollectionBehavior = 'Warn' + SiteType = 'Primary' + EnableWakeOnLan = $true + WakeOnLanTransmissionMethodType = 'Unicast' + RetryNumberOfSendingWakeupPacketTransmission = 1 + SendingWakeupPacketTransmissionDelayMins = 10000 + MaximumNumberOfSendingWakeupPacketBeforePausing = 10 + SendingWakeupPacketBeforePausingWaitSec = 3 + ThreadNumberOfSendingWakeupPacket = 10 + SendingWakeupPacketTransmissionOffsetMins = 10 + ClientCertificateCustomStoreName = 'SMSStore' + TakeActionForMultipleCertificateMatchCriteria = 'SelectCertificateWithLongestValidityPeriod' + ClientCertificateSelectionCriteriaType = 'ClientAuthentication' + ClientCertificateSelectionCriteriaValue = '' + } + + Mock -CommandName Import-ConfigMgrPowerShellModule + Mock -CommandName Set-Location + Mock -CommandName Set-CMSite + } + + Context 'When Set-TargetResource runs successfully' { + BeforeEach { + $getReturnCas = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + ClientComputerCommunicationType = 'HttpsOrHttp' + ClientCheckCertificateRevocationListForSiteSystem = $null + UsePkiClientCertificate = $null + UseSmsGeneratedCert = $true + RequireSigning = $null + RequireSha256 = $null + UseEncryption = $null + MaximumConcurrentSendingForAllSite = 6 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 2 + ConcurrentSendingDelayBeforeRetryingMins = 10 + EnableLowFreeSpaceAlert = $null + FreeSpaceThresholdWarningGB = $null + FreeSpaceThresholdCriticalGB = $null + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 1000 + SiteSystemCollectionBehavior = 'Warn' + SiteType = 'Cas' + } + + $inputNotMatch = @{ + SiteCode = 'Lab' + EnableLowFreeSpaceAlert = $false + } + + $casMisMatch = @{ + SiteCode = 'Lab' + EnableLowFreeSpaceAlert = $false + FreeSpaceThresholdWarningGB = 10 + FreeSpaceThresholdCriticalGB = 20 + } + + $inputAlerts = @{ + SiteCode = 'Lab' + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 20 + FreeSpaceThresholdCriticalGB = 10 + } + + $inputDefaultThresholdMismatch = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + ThresholdOfSelectCollectionByDefault = 101 + } + + $collectionDefault = @{ + SiteCode = 'Lab' + ThresholdOfSelectCollectionByDefault = 99 + } + + $collectionMax = @{ + SiteCode = 'Lab' + ThresholdOfSelectCollectionMax = 999 + } + + $alertSetting = @{ + SiteCode = 'Lab' + FreeSpaceThresholdWarningGB = 20 + FreeSpaceThresholdCriticalGB = 10 + } + + $ignoreSMSCert = @{ + SiteCode = 'Lab' + UseSmsGeneratedCert = $true + ClientComputerCommunicationType = 'HttpsOnly' + } + + $inputWakeFalse = @{ + SiteCode = 'Lab' + EnableWakeOnLan = $false + RetryNumberOfSendingWakeupPacketTransmission = 3 + } + + $inputBadAuth = @{ + SiteCode = 'Lab' + ClientCertificateSelectionCriteriaType = 'ClientAuthentication' + ClientCertificateSelectionCriteriaValue = 'Test' + } + + $inputAuthString = @{ + SiteCode = 'Lab' + ClientCertificateSelectionCriteriaType = 'CertificateSubjectContainsString' + ClientCertificateSelectionCriteriaValue = 'Test' + } + + $inputNullCert = @{ + SiteCode = 'Lab' + ClientCertificateCustomStoreName = '' + } + } + + It 'Should call expected commands for when changing settings for Primary' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @inputDefaultThresholdMismatch + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands for when changing settings for Cas' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnCas } + + Set-TargetResource @inputDefaultThresholdMismatch + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands for when changing settings for Primary only settings' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @inputNotMatch + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands for when changing Alert settings' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @inputAlerts + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands for when specifying Alert settings and enabling alerts is not specified' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @alertSetting + 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 Set-CMSite -Exactly -Times 0 -Scope It + } + + It 'Should call expected commands when specifying UseSmsGeneratedCert and setting ClientComputerCommunicationType to HttpsOnly' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @ignoreSMSCert + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands for when changing settings for Cas and specifying Primary only settings' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnCas } + + Set-TargetResource @casMisMatch + 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 Set-CMSite -Exactly -Times 0 -Scope It + } + + It 'Should call expected commands for when changing settings for default collection settings' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnCas } + + Set-TargetResource @collectionDefault + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands for when changing settings for max collection settings' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnCas } + + Set-TargetResource @collectionMax + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands Wake On Lan false is specified along with additional Wake On Lan parameters' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @inputWakeFalse + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands when ClientCertificateSelectionCriteriaType is erroniously specified' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @inputBadAuth + 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 Set-CMSite -Exactly -Times 0 -Scope It + } + + It 'Should call expected commands when ClientCertificateSelectionCriteriaType is changed' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @inputAuthString + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + + It 'Should call expected commands when changing the certificate store with a null string input' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + Set-TargetResource @inputNullCert + 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 Set-CMSite -Exactly -Times 1 -Scope It + } + } + + Context 'When Set-TargetResource throws' { + BeforeEach { + $inputCollectionBad = @{ + SiteCode = 'Lab' + ThresholdOfSelectCollectionByDefault = 9 + ThresholdOfSelectCollectionMax = 1 + } + + $inputEnableAlertCrit = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdCriticalGB = 6 + } + + $inputEnableAlertInvalid = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 5 + FreeSpaceThresholdCriticalGB = 10 + } + + $inputMissingValue = @{ + SiteCode = 'Lab' + ClientCertificateSelectionCriteriaType = 'CertificateSubjectContainsString' + } + + $inputMissingType = @{ + SiteCode = 'Lab' + ClientCertificateSelectionCriteriaValue = 'Test' + } + + $collectionError = 'ThresholdOfSelectCollectionByDefault of: 9 must be less than ThresholdOfSelectCollectionMax: 1.' + $alertMissing = 'When setting EnableLowFreeSpaceAlert to true, FreeSpaceThreshold warning and critical must be specified.' + $alertErrorMsg = 'FreeSpaceThresholdCritical is greater than or equal to FreeSpaceThresholdWarning. Warning should be greater than Critical.' + $certValueError = 'When ClientCertificateSelectionCriteriaType is specified as CertificateSubjectContainsString, ClientCertificateSelectionCriteriaValue is required.' + $missingCertType = 'When ClientCertificateSelectionCriteriaValue is specified, ClientCertificateSelectionCriteriaType is required.' + } + + It 'Should call expected commands and throw when collection default is greater than collection max' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + { Set-TargetResource @inputCollectionBad } | Should -Throw -ExpectedMessage $collectionError + 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 Set-CMSite -Exactly -Times 0 -Scope It + } + + It 'Should call expected commands and throw when not all params are specified when setting Alerts to enabled' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + { Set-TargetResource @inputEnableAlertCrit } | Should -Throw -ExpectedMessage $alertMissing + 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 Set-CMSite -Exactly -Times 0 -Scope It + } + + It 'Should call expected commands and throw when not all params are specified when setting Alerts settings are invalid' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + { Set-TargetResource @inputEnableAlertInvalid } | Should -Throw -ExpectedMessage $alertErrorMsg + 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 Set-CMSite -Exactly -Times 0 -Scope It + } + + It 'Should call expected commands and throw when ClientCertificateSelectionCriteriaValue is required but omitted' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + { Set-TargetResource @inputMissingValue } | Should -Throw -ExpectedMessage $certValueError + 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 Set-CMSite -Exactly -Times 0 -Scope It + } + + It 'Should call expected commands and throw when ClientCertificateSelectionCriteriaType is required but omitted' { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + + { Set-TargetResource @inputMissingType } | Should -Throw -ExpectedMessage $missingCertType + 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 Set-CMSite -Exactly -Times 0 -Scope It + } + } + } + + Describe 'ConfigMgrCBDsc - DSC_CMSiteConfiguration\Test-TargetResource' -Tag 'Test' { + BeforeAll { + $getReturnAll = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + ClientComputerCommunicationType = 'HttpsOrHttp' + ClientCheckCertificateRevocationListForSiteSystem = $true + UsePkiClientCertificate = $false + UseSmsGeneratedCert = $true + RequireSigning = $true + RequireSha256 = $false + UseEncryption = $false + MaximumConcurrentSendingForAllSite = 6 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 2 + ConcurrentSendingDelayBeforeRetryingMins = 10 + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 10 + FreeSpaceThresholdCriticalGB = 5 + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 1000 + SiteSystemCollectionBehavior = 'Warn' + SiteType = 'Primary' + EnableWakeOnLan = $true + WakeOnLanTransmissionMethodType = 'Unicast' + RetryNumberOfSendingWakeupPacketTransmission = 1 + SendingWakeupPacketTransmissionDelayMins = 10000 + MaximumNumberOfSendingWakeupPacketBeforePausing = 10 + SendingWakeupPacketBeforePausingWaitSec = 3 + ThreadNumberOfSendingWakeupPacket = 10 + SendingWakeupPacketTransmissionOffsetMins = 10 + ClientCertificateCustomStoreName = 'SMSStore' + TakeActionForMultipleCertificateMatchCriteria = 'SelectCertificateWithLongestValidityPeriod' + ClientCertificateSelectionCriteriaType = 'ClientAuthentication' + ClientCertificateSelectionCriteriaValue = 'Personal' + } + + $getReturnCas = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + ClientComputerCommunicationType = 'HttpsOrHttp' + ClientCheckCertificateRevocationListForSiteSystem = $null + UsePkiClientCertificate = $null + UseSmsGeneratedCert = $true + RequireSigning = $null + RequireSha256 = $null + UseEncryption = $null + MaximumConcurrentSendingForAllSite = 6 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 2 + ConcurrentSendingDelayBeforeRetryingMins = 10 + EnableLowFreeSpaceAlert = $null + FreeSpaceThresholdWarningGB = $null + FreeSpaceThresholdCriticalGB = $null + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 1000 + SiteSystemCollectionBehavior = 'Warn' + SiteType = 'Cas' + } + + $getReturnAlertDisabled = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + ClientComputerCommunicationType = 'HttpsOrHttp' + ClientCheckCertificateRevocationListForSiteSystem = $true + UsePkiClientCertificate = $false + UseSmsGeneratedCert = $true + RequireSigning = $true + RequireSha256 = $false + UseEncryption = $false + MaximumConcurrentSendingForAllSite = 6 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 2 + ConcurrentSendingDelayBeforeRetryingMins = 10 + EnableLowFreeSpaceAlert = $false + FreeSpaceThresholdWarningGB = $null + FreeSpaceThresholdCriticalGB = $null + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 1000 + SiteSystemCollectionBehavior = 'Warn' + SiteType = 'Primary' + EnableWakeOnLan = $true + WakeOnLanTransmissionMethodType = 'Unicast' + RetryNumberOfSendingWakeupPacketTransmission = 1 + SendingWakeupPacketTransmissionDelayMins = 10000 + MaximumNumberOfSendingWakeupPacketBeforePausing = 10 + SendingWakeupPacketBeforePausingWaitSec = 3 + ThreadNumberOfSendingWakeupPacket = 10 + SendingWakeupPacketTransmissionOffsetMins = 10 + ClientCertificateCustomStoreName = 'SMSStore' + TakeActionForMultipleCertificateMatchCriteria = 'SelectCertificateWithLongestValidityPeriod' + ClientCertificateSelectionCriteriaType = 'ClientAuthentication' + ClientCertificateSelectionCriteriaValue = 'Personal' + } + + $inputMatch = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + ClientComputerCommunicationType = 'HttpsOrHttp' + MaximumConcurrentSendingForAllSite = 6 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 2 + ConcurrentSendingDelayBeforeRetryingMins = 10 + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 10 + FreeSpaceThresholdCriticalGB = 5 + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 1000 + SiteSystemCollectionBehavior = 'Warn' + } + + $inputNotMatch = @{ + SiteCode = 'Lab' + EnableLowFreeSpaceAlert = $false + } + + $inputAlertsWarning = @{ + SiteCode = 'Lab' + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 10 + FreeSpaceThresholdCriticalGB = 20 + } + + $casMisMatch = @{ + SiteCode = 'Lab' + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 10 + FreeSpaceThresholdCriticalGB = 20 + } + + $inputSmsCertWithHttpsOnly = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + ClientComputerCommunicationType = 'HttpsOnly' + UseSmsGeneratedCert = $true + } + + $inputEnableAlertWithValue = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 11 + FreeSpaceThresholdCriticalGB = 6 + } + + $inputEnableAlertCrit = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdCriticalGB = 6 + } + + $inputDisableAlertCrit = @{ + SiteCode = 'Lab' + Comment = 'Site Lab' + EnableLowFreeSpaceAlert = $false + FreeSpaceThresholdCriticalGB = 6 + } + + $collectionDefault = @{ + SiteCode = 'Lab' + ThresholdOfSelectCollectionByDefault = 99 + } + + $collectionMax = @{ + SiteCode = 'Lab' + ThresholdOfSelectCollectionMax = 999 + } + + $collectionBad = @{ + SiteCode = 'Lab' + ThresholdOfSelectCollectionByDefault = 9 + ThresholdOfSelectCollectionMax = 1 + } + + $inputWakeFalse = @{ + SiteCode = 'Lab' + EnableWakeOnLan = $false + RetryNumberOfSendingWakeupPacketTransmission = 3 + } + + $inputBadAuth = @{ + SiteCode = 'Lab' + ClientCertificateSelectionCriteriaType = 'ClientAuthentication' + ClientCertificateSelectionCriteriaValue = 'Test' + } + + $inputMissingValue = @{ + SiteCode = 'Lab' + ClientCertificateSelectionCriteriaType = 'CertificateSubjectContainsString' + } + + $inputMissingType = @{ + SiteCode = 'Lab' + ClientCertificateSelectionCriteriaValue = 'Test' + } + + $inputAuthString = @{ + SiteCode = 'Lab' + ClientCertificateSelectionCriteriaType = 'CertificateSubjectContainsString' + ClientCertificateSelectionCriteriaValue = 'Test' + } + + $inputNullCert = @{ + SiteCode = 'Lab' + ClientCertificateCustomStoreName = '' + } + + Mock -CommandName Import-ConfigMgrPowerShellModule + Mock -CommandName Set-Location + } + + Context 'When running Test-TargetResource for Primary Server' { + BeforeEach { + Mock -CommandName Get-TargetResource -MockWith { $getReturnAll } + } + + It 'Should return desired result true when desired results equals current state' { + + Test-TargetResource @inputMatch | Should -Be $true + } + + It 'Should return desired result false when desired result does not equal current state' { + + Test-TargetResource @inputNotMatch | Should -Be $false + } + + It 'Should return desired result false when desired result does not equal current state with invalid parameter' { + + Test-TargetResource @inputSmsCertWithHttpsOnly | Should -Be $false + } + + It 'Should return desired result false when desired result when only specifying warning alert settings' { + + Test-TargetResource @inputEnableAlertCrit | Should -Be $false + } + + It 'Should return desired result false when desired result does not equal current state with enabling Alerts bad input' { + + Test-TargetResource @inputAlertsWarning | Should -Be $false + } + + It 'Should return desired result false when collection default does not match' { + + Test-TargetResource @collectionDefault | Should -Be $false + } + + It 'Should return desired result false when collection max does not match' { + + Test-TargetResource @collectionMax | Should -Be $false + } + + It 'Should return desired result false when collection default and max values are not valid' { + + Test-TargetResource @collectionBad | Should -Be $false + } + + It 'Should return desired result false when specifying alert settings and settings alerts to disabled' { + + Test-TargetResource @inputDisableAlertCrit | Should -Be $false + } + + It 'Should return desired result false when WOL is specified false and warn for bad params' { + + Test-TargetResource @inputWakeFalse | Should -Be $false + } + + It 'Should return desired result true fpr Cert Selection type and warn for bad params' { + + Test-TargetResource @inputBadAuth | Should -Be $true + } + + It 'Should return desired result false when ClientCertificateSelectionCriteriaValue is missing' { + + Test-TargetResource @inputMissingValue | Should -Be $false + } + + It 'Should return desired result false when ClientCertificateSelectionCriteriaType is missing' { + + Test-TargetResource @inputMissingType | Should -Be $false + } + + It 'Should return desired result false when ClientCertificateSelectionCriteriaType is mismatched' { + + Test-TargetResource @inputAuthString | Should -Be $false + } + + It 'Should return desired result false when Certificate Store mismatched and warn when null' { + + Test-TargetResource @inputNullCert | Should -Be $false + } + } + + Context 'When running Test-TargetResource for Cas Server' { + BeforeEach { + Mock -CommandName Get-TargetResource -MockWith { $getReturnCas } + } + + It 'Should return desired result true when desired result specifying Primary Setting on Cas' { + + Test-TargetResource @casMisMatch | Should -Be $true + } + } + } + } +} +finally +{ + Invoke-TestCleanup +} diff --git a/tests/Unit/ConfigMgrCBDsc.ReverseDsc.tests.ps1 b/tests/Unit/ConfigMgrCBDsc.ReverseDsc.tests.ps1 index 46056bb..ef84286 100644 --- a/tests/Unit/ConfigMgrCBDsc.ReverseDsc.tests.ps1 +++ b/tests/Unit/ConfigMgrCBDsc.ReverseDsc.tests.ps1 @@ -3111,6 +3111,206 @@ InModuleScope $script:subModuleName { } ) } + @{ + ImplementedAs = 'PowerShell' + Name = 'CMSiteConfiguration' + ModuleName = 'ConfigMgrCBDsc' + Version = '1.0.1' + Properties = @( + @{ + Name = 'SiteCode' + PropertyType = '[string]' + IsMandatory = $true + Values = '{}' + } + @{ + Name = 'Comment' + PropertyType = '[string]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'ClientComputerCommunicationType' + PropertyType = '[string]' + IsMandatory = $false + Values = '{HttpsOnly,HttpsOrHttp}' + } + @{ + Name = 'ClientCheckCertificateRevocationListForSiteSystem' + PropertyType = '[bool]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'UsePkiClientCertificate' + PropertyType = '[bool]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'UseSmsGeneratedCert' + PropertyType = '[bool]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'RequireSigning' + PropertyType = '[bool]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'RequireSha256' + PropertyType = '[bool]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'UseEncryption' + PropertyType = '[bool]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'MaximumConcurrentSendingForAllSite' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'MaximumConcurrentSendingForPerSite' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'RetryNumberForConcurrentSending' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'ConcurrentSendingDelayBeforeRetryingMins' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'EnableLowFreeSpaceAlert' + PropertyType = '[bool]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'FreeSpaceThresholdWarningGB' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'FreeSpaceThresholdCriticalGB' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'ThresholdOfSelectCollectionByDefault' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'ThresholdOfSelectCollectionMax' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'SiteSystemCollectionBehavior' + PropertyType = '[string]' + IsMandatory = $false + Values = '{Warn,Block}' + } + @{ + Name = 'EnableWakeOnLan' + PropertyType = '[bool]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'WakeOnLanTransmissionMethodType' + PropertyType = '[string]' + IsMandatory = $false + Values = '{Unicast,SubnetDirectedBroadcasts}' + } + @{ + Name = 'RetryNumberOfSendingWakeupPacketTransmission' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'SendingWakeupPacketTransmissionDelayMins' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'MaximumNumberOfSendingWakeupPacketBeforePausing' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'SendingWakeupPacketBeforePausingWaitSec' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'ThreadNumberOfSendingWakeupPacket' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'SendingWakeupPacketTransmissionOffsetMins' + PropertyType = '[UInt32]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'ClientCertificateCustomStoreName' + PropertyType = '[string]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'TakeActionForMultipleCertificateMatchCriteria' + PropertyType = '[string]' + IsMandatory = $false + Values = '{FailSelectionAndSendErrorMessage,SelectCertificateWithLongestValidityPeriod}' + } + @{ + Name = 'ClientCertificateSelectionCriteriaType' + PropertyType = '[string]' + IsMandatory = $false + Values = '{ClientAuthentication,CertificateSubjectContainsString,CertificateSubjectOrSanIncludesAttributes}' + } + @{ + Name = 'ClientCertificateSelectionCriteriaValue' + PropertyType = '[string]' + IsMandatory = $false + Values = '{}' + } + @{ + Name = 'PsDscRunAsCredential' + PropertyType = '[PSCredential]' + IsMandatory = $false + Values = '{}' + } + ) + } @{ ImplementedAs = 'PowerShell' Name = 'CMSiteMaintenance' @@ -5912,6 +6112,74 @@ InModuleScope $script:subModuleName { SiteCode = 'Lab' PSComputerName = 'localhost' } + + $siteConfig = @{ + SiteCode = 'Lab' + Include = 'SiteConfiguration' + } + + $invokeSiteConfigurationPri = @{ + ConfigurationName = $null + DependsOn = $null + ModuleName = 'ConfigMgrCBDsc' + ModuleVersion = 1.0.1 + PsDscRunAsCredential = $null + ResourceId = $null + SourceInfo = $null + SiteCode = 'Lab' + Comment = 'Site Lab' + ClientComputerCommunicationType = 'HttpsOrHttp' + ClientCheckCertificateRevocationListForSiteSystem = $true + UsePkiClientCertificate = $false + UseSmsGeneratedCert = $true + RequireSigning = $true + RequireSha256 = $false + UseEncryption = $false + MaximumConcurrentSendingForAllSite = 6 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 2 + ConcurrentSendingDelayBeforeRetryingMins = 10 + EnableLowFreeSpaceAlert = $true + FreeSpaceThresholdWarningGB = 10 + FreeSpaceThresholdCriticalGB = 5 + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 1000 + SiteSystemCollectionBehavior = 'Warn' + SiteType = 'Primary' + EnableWakeOnLan = $true + WakeOnLanTransmissionMethodType = 'Unicast' + RetryNumberOfSendingWakeupPacketTransmission = 1 + SendingWakeupPacketTransmissionDelayMins = 10000 + MaximumNumberOfSendingWakeupPacketBeforePausing = 10 + SendingWakeupPacketBeforePausingWaitSec = 3 + ThreadNumberOfSendingWakeupPacket = 10 + SendingWakeupPacketTransmissionOffsetMins = 10 + ClientCertificateCustomStoreName = 'SMSStore' + TakeActionForMultipleCertificateMatchCriteria = 'SelectCertificateWithLongestValidityPeriod' + ClientCertificateSelectionCriteriaType = 'ClientAuthentication' + ClientCertificateSelectionCriteriaValue = 'Personal' + PSComputerName = 'localhost' + } + + $invokeSiteConfigurationCas = @{ + ConfigurationName = $null + DependsOn = $null + ModuleName = 'ConfigMgrCBDsc' + ModuleVersion = 1.0.1 + PsDscRunAsCredential = $null + ResourceId = $null + SourceInfo = $null + SiteCode = 'Lab' + Comment = 'Lab Site CAS' + MaximumConcurrentSendingForAllSite = 5 + MaximumConcurrentSendingForPerSite = 3 + RetryNumberForConcurrentSending = 10 + ConcurrentSendingDelayBeforeRetryingMins = 5 + ThresholdOfSelectCollectionByDefault = 100 + ThresholdOfSelectCollectionMax = 0 + SiteSystemCollectionBehavior = 'Block' + PSComputerName = 'localhost' + } } Context 'When running the Set-ConfigMgrCBDscReverse' { @@ -6009,11 +6277,12 @@ InModuleScope $script:subModuleName { Mock -CommandName Invoke-DscResource -MockWith { $invokeCMClientSettingsUpdate } -ParameterFilter { $Name -eq 'CMClientSettingsSoftwareUpdate' } Mock -CommandName Invoke-DscResource -MockWith { $invokeCMClientSettingsStateMessaging } -ParameterFilter { $Name -eq 'CMClientSettingsStateMessaging' } Mock -CommandName Invoke-DscResource -MockWith { $invokeCMClientSettingsUserDeviceAffinity } -ParameterFilter { $Name -eq 'CMClientSettingsUserDeviceAffinity' } + Mock -CommandName Invoke-DscResource -MockWith { $invokeSiteConfigurationCas } -ParameterFilter { $Name -eq 'CMSiteConfiguration' } $result = Set-ConfigMgrCBDscReverse @testAll $result | Should -BeOfType System.String Assert-MockCalled Get-CMAccount -Exactly -Times 1 -Scope It - Assert-MockCalled Invoke-DscResource -Exactly -Times 46 -Scope It + Assert-MockCalled Invoke-DscResource -Exactly -Times 47 -Scope It Assert-MockCalled Get-CMAdministrativeUser -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMClientSetting -Exactly -Times 19 -Scope It @@ -6027,7 +6296,7 @@ InModuleScope $script:subModuleName { Assert-MockCalled Get-CMReportingServicePoint -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMSecurityScope -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMServiceConnectionPoint -Exactly -Times 1 -Scope It - Assert-MockCalled Get-CMSiteDefinition -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMSiteDefinition -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMSoftwareUpdatePoint -Exactly -Times 1 -Scope It Assert-MockCalled Get-CMSite -Exactly -Times 1 -Scope It @@ -6447,6 +6716,40 @@ InModuleScope $script:subModuleName { Assert-MockCalled New-Configuration -Exactly -Times 0 -Scope It } + It 'Should return expected results and call expected commands for Site Configuration Primary' { + Mock -CommandName Get-DscResource -MockWith { $getDscResourceReturn } + Mock -CommandName Invoke-DscResource -MockWith { $invokeSiteConfigurationPri } + Mock -CommandName Get-CMSiteDefinition -MockWith { $getCMDefinitionPrimary } + + $result = Set-ConfigMgrCBDscReverse @siteConfig + $result | Should -BeOfType System.String + $result | Should -Match "CMSiteConfiguration" + Assert-MockCalled Get-CMAccount -Exactly -Times 0 -Scope It + Assert-MockCalled Invoke-DscResource -Exactly -Times 1 -Scope It + Assert-MockCalled Get-CMAdministrativeUser -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMAssetIntelligenceSynchronizationPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMClientSetting -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMCollection -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMDistributionPointGroup -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMDistributionPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMFallbackStatusPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMDiscoveryMethod -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMManagementPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMDistributionPointInfo -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMReportingServicePoint -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMSecurityScope -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMServiceConnectionPoint -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMSiteDefinition -Exactly -Times 1 -Scope It + Assert-MockCalled Get-CMSiteSystemServer -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMSoftwareUpdatePoint -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMMaintenanceWindow -Exactly -Times 0 -Scope It + Assert-MockCalled Get-CMBoundaryGroup -Exactly -Times 0 -Scope It + Assert-MockCalled Test-Path -Exactly -Times 0 -Scope It + Assert-MockCalled Remove-Item -Exactly -Times 0 -Scope It + Assert-MockCalled Add-Content -Exactly -Times 0 -Scope It + Assert-MockCalled New-Configuration -Exactly -Times 0 -Scope It + } + It 'Should return expected results and call expected commands for Site System Server' { Mock -CommandName Get-DscResource -MockWith { $getDscResourceReturn } Mock -CommandName Invoke-DscResource -MockWith { $invokeSiteSystemProxy }