Skip to content

Commit

Permalink
Merge pull request #58 from dsccommunity/CMUserDiscovery
Browse files Browse the repository at this point in the history
CMUserDiscovery: A Resource to configure the SCCM User Discovery Method
  • Loading branch information
NEllis280 authored Jul 27, 2020
2 parents c8af2c0 + 3f3cf7d commit d2a9deb
Show file tree
Hide file tree
Showing 15 changed files with 1,603 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added CMCMCollectionMembershipEvaluationComponent Resource
- Added CMDistributionPointGroupMembers Resource
- Added CMSecurityScopes Resource
- Added CMUserDiscovery Resource

### Changed

Expand All @@ -69,6 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added Security Scopes to CMDistributionGroup Resource
- Added SiteSystems, SiteSystemsToInclude, and SiteSystemsToExclude and SecurityScopes,
SecurityScopesToInclude, SecurityScopesToExclude to CMBoundaryGroup resource.
- Updated CMSystemDiscovery Resource to add needed throw and warn messages.

### Removed

Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ Please check out common DSC Community [contributing guidelines](https://dsccommu
- **CMSecurityScopes**: Provides a resource for adding and removing Security
Scopes. Note: If the Security Scope is currently in use and assigned, DSC will
not remove the Security Scope.
- **CMUserDiscovery**: Provides a resource to manage the Configuration Manager
User Discovery method.

### xSccmPreReqs

Expand Down Expand Up @@ -1056,3 +1058,37 @@ Please check out common DSC Community [contributing guidelines](https://dsccommu

- [CMSecurityScopes_Present](Source\Examples\Resources\CMSecurityScopes\CMSecurityScopes_Present.ps1)
- [CMSecurityScopes_Absent](Source\Examples\Resources\CMSecurityScopes\CMSecurityScopes_Absent.ps1)

### CMUserDiscovery

- **[String] SiteCode** _(Key)_: Specifies the Site Code for the Configuration
Manager site.
- **[Boolean] Enabled** _(Key)_: Specifies the enablement of the User
Discovery method. If settings is set to $false no other value provided will be
evaluated for compliance.
- **[Boolean] EnableDeltaDiscovery** _(Write)_: Indicates whether Configuration
Manager discovers resources created or modified in AD DS since the last
discovery cycle.
- **[UInt32] DeltaDiscoveryMins** _(Write)_: Specifies the number of minutes for
the delta discovery.
- **[String] ADContainers[]** _(Write)_: Specifies an array of names of Active Directory
containers to match to the discovery.
- **[String] ADContainersToInclude[]** _(Write)_: Specifies an array of names of
Active Directory containers to add to the discovery.
- **[String] ADContainersToExclude[]** _(Write)_: Specifies an array of names of
Active Directory containers to exclude to the discovery.
- **[String] ScheduleInterval** _(Write)_: Specifies the time when the scheduled
event recurs in hours and days.
- Values include: { None| Days| Hours | Minutes }
- **[UInt32] ScheduleCount** _(Write)_: Specifies how often the recur interval
is run. If hours are specified the max value is 23. Anything over 23 will result
in 23 to be set. If days are specified the max value is 31. Anything over 31 will
result in 31 being set.

#### CMUserDiscovery Examples

- [CMUserDiscovery_Disabled](Source\Examples\Resources\CMUserDiscovery\CMUserDiscovery_Disabled.ps1)
- [CMUserDiscovery_Enabled](Source\Examples\Resources\CMUserDiscovery\CMUserDiscovery_Enabled.ps1)
- [CMUserDiscovery_Exclude](Source\Examples\Resources\CMUserDiscovery\CMUserDiscovery_Exclude.ps1)
- [CMUserDiscovery_Include](Source\Examples\Resources\CMUserDiscovery\CMUserDiscovery_Include.ps1)
- [CMUserDiscovery_ScheduleNone](Source\Examples\Resources\CMUserDiscovery\CMUserDiscovery_ScheduleNone.ps1)
3 changes: 2 additions & 1 deletion source/ConfigMgrCBDsc.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
'CMCollectionMembershipEvaluationComponent'
'CMDistributionPointGroupMembers'
'CMSecurityScopes'
'CMUserDiscovery'
)

<#
Expand All @@ -90,7 +91,7 @@
'ManagementPoint','AssetIntelligencePoint','FallbackStatusPoint','SoftwareUpdatePoint','DistrubtionPoint','HeartbeatDiscovery',
'ServiceConnectionPoint','NetworkDiscovery','ReportingServicePoint','SystemDiscovery','PXEDistributionPoint','PullDistributionPoint',
'SiteMaintenance','AdministrativeUser','DistributionGroup','SiteSystemServer','StatusReportingComponent','CollectionMembershipEvaluationComponent',
'DistributionPointGroupMembers','SecurityScopes')
'DistributionPointGroupMembers','SecurityScopes','UserDiscovery')

# A URL to the license for this module.
LicenseUri = 'https://github.com/dsccommunity/ConfigMgrCBDsc/blob/master/LICENSE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,29 @@ function Set-TargetResource
throw $script:localizedData.MissingDeltaDiscovery
}

if (($PSBoundParameters.ContainsKey('ScheduleInterval') -and $PSBoundParameters.ScheduleInterval -ne 'None') -and (-not $PSBoundParameters.ContainsKey('ScheduleCount')))
if (($PSBoundParameters.ContainsKey('ScheduleInterval') -and $PSBoundParameters.ScheduleInterval -ne 'None') -and
(-not $PSBoundParameters.ContainsKey('ScheduleCount')))
{
throw $script:localizedData.IntervalCount
}

if (($EnableDeltaDiscovery -eq $true -and $state.EnableDeltaDiscovery -eq $false) -and
(-not $PSBoundParameters.ContainsKey('DeltaDiscoveryMins')))
{
throw $script:localizedData.DeltaNoInterval
}

if ($ADContainersToInclude -and $ADContainersToExclude)
{
foreach ($item in $ADContainersToInclude)
{
if ($ADContainersToExclude -contains $item)
{
throw ($script:localizedData.ContainersInEx -f $item)
}
}
}

$paramsToCheck = @('Enabled','EnableDeltaDiscovery','DeltaDiscoveryMins','EnableFilteringExpiredLogon',
'TimeSinceLastLogonDays','EnableFilteringExpiredPassword','TimeSinceLastPasswordUpdateDays')

Expand Down Expand Up @@ -506,7 +524,7 @@ function Test-TargetResource
{
if ($ScheduleInterval -ne 'None' -and -not $PSBoundParameters.ContainsKey('ScheduleCount'))
{
Write-Verbose -Message $script:localizedData.IntervalCount
Write-Warning -Message $script:localizedData.IntervalCount
$result = $false
}
else
Expand All @@ -525,6 +543,23 @@ function Test-TargetResource
}
}

if (($EnableDeltaDiscovery -eq $true -and $state.EnableDeltaDiscovery -eq $false) -and
(-not $PSBoundParameters.ContainsKey('DeltaDiscoveryMins')))
{
Write-Warning -Message $script:localizedData.DeltaNoInterval
}

if ($ADContainersToInclude -and $ADContainersToExclude)
{
foreach ($item in $ADContainersToInclude)
{
if ($ADContainersToExclude -contains $item)
{
Write-Warning -Message ($script:localizedData.ContainersInEx -f $item)
}
}
}

if (($ADContainers) -or ($ADContainersToInclude))
{
if ($ADContainers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ ConvertFrom-StringData @'
SetDisabled = Setting System Discovery to disabled.
MissingDeltaDiscovery = When changing delta schedule, delta schedule must be enabled.
ADIgnore = ADContainers was specified, ADContainersInclude and ADContainersExclude will be ignored.
ContainersInEx = ADContainersToExclude and ADContainersToInclude contain to same entry {0}, remove from one of the arrays.
DeltaNoInterval = DeltaDiscoveryMins is not specified, specify DeltaDiscoveryMins when enabling Delta Discovery.
'@
Loading

0 comments on commit d2a9deb

Please sign in to comment.