Skip to content

Commit

Permalink
Migrate to Using DscResource.Common Functions Module (#598)
Browse files Browse the repository at this point in the history
- ActiveDirectoryDsc
  - Migrated to DscResource.Common Module.
  • Loading branch information
X-Guardian authored Apr 19, 2020
1 parent 7cd1ab1 commit d648714
Show file tree
Hide file tree
Showing 29 changed files with 237 additions and 657 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)

## [Unreleased]

### Changed

- ActiveDirectoryDsc
- Migrated to DscResource.Common Module.

## [6.0.1] - 2020-04-16

### Fixed
Expand Down
1 change: 1 addition & 0 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ModuleBuilder = '1.0.0'
ChangelogManagement = 'latest'
Sampler = 'latest'
'DscResource.Common' = '0.5.0'
'DscResource.Test' = 'latest'
'DscResource.AnalyzerRules' = 'latest'
xDscResourceDesigner = 'latest'
Expand Down
10 changes: 8 additions & 2 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ CopyDirectories:
Encoding: UTF8 # With BOM in WinPS, noBOM in PSCore.
VersionedOutputDirectory: true

NestedModule:
DscResource.Common:
CopyOnly: true
Path: ./output/RequiredModules/DscResource.Common
AddToManifest: false
Exclude: PSGetModuleInfo.xml

####################################################
# Sampler Pipeline Configuration #
Expand Down Expand Up @@ -49,6 +55,7 @@ BuildWorkflow:
Pester:
OutputFormat: NUnitXML
ExcludeFromCodeCoverage:
- Modules/DscResource.Common
Script:
- tests/Unit
ExcludeTag:
Expand All @@ -64,8 +71,7 @@ DscTest:
ExcludeSourceFile:
- output
ExcludeModuleFile:
# - Templates
# - Modules/DscResource.Common
- Modules/DscResource.Common

Resolve-Dependency: #Parameters for Resolve-Dependency
#PSDependTarget: ./output/modules
Expand Down
13 changes: 8 additions & 5 deletions source/DSCResources/MSFT_ADComputer/MSFT_ADComputer.psm1
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADComputer'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
A property map that maps the resource parameters to the corresponding
Expand Down
17 changes: 10 additions & 7 deletions source/DSCResources/MSFT_ADDomain/MSFT_ADDomain.psm1
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADDomain'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
.SYNOPSIS
Expand Down Expand Up @@ -33,9 +36,9 @@ $script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADDomain'
-------------------------------|--------------------------
Get-ADDomain | ActiveDirectory
Get-ADForest | ActiveDirectory
Assert-Module | ActiveDirectoryDsc.Common
Assert-Module | DscResource.Common
New-InvalidOperationException | DscResource.Common
Resolve-DomainFQDN | ActiveDirectoryDsc.Common
New-InvalidOperationException | ActiveDirectoryDsc.Common
ConvertTo-DeploymentForestMode | ActiveDirectoryDsc.Common
ConvertTo-DeploymentDomainMode | ActiveDirectoryDsc.Common
#>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADDomainController'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
.SYNOPSIS
Expand All @@ -28,7 +31,8 @@ $script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADDomainController
Get-ADDomain | ActiveDirectory
Get-ADDomainControllerPasswordReplicationPolicy | ActiveDirectory
Get-DomainControllerObject | ActiveDirectoryDsc.Common
Assert-Module | ActiveDirectoryDsc.Common
Assert-Module | DscResource.Common
New-ObjectNotFoundException | DscResource.Common
#>
function Get-TargetResource
{
Expand Down Expand Up @@ -195,7 +199,7 @@ function Get-TargetResource
Remove-ADDomainControllerPasswordReplicationPolicy | ActiveDirectory
Add-ADDomainControllerPasswordReplicationPolicy | ActiveDirectory
Get-DomainControllerObject | ActiveDirectoryDsc.Common
New-InvalidOperationException | ActiveDirectoryDsc.Common
New-InvalidOperationException | DscResource.Common
#>
function Set-TargetResource
{
Expand Down Expand Up @@ -604,9 +608,9 @@ function Set-TargetResource
Name | Module
------------------------------|--------------------------
Test-ADReplicationSite | ActiveDirectoryDsc.Common
New-InvalidOperationException | ActiveDirectoryDsc.Common
New-ObjectNotFoundException | ActiveDirectoryDsc.Common
Test-Members | ActiveDirectoryDsc.Common
New-InvalidOperationException | DscResource.Common
New-ObjectNotFoundException | DscResource.Common
#>
function Test-TargetResource
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADDomainControllerProperties'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADDomainDefaultPasswordPolicy'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

# List of changeable policy properties
$mutablePropertyMap = @(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADDomainFunctionalLevel'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
.SYNOPSIS
Expand Down
13 changes: 8 additions & 5 deletions source/DSCResources/MSFT_ADDomainTrust/MSFT_ADDomainTrust.psm1
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADDomainTrust'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADForestFunctionalLevel'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADForestProperties'
$script:psModuleName = 'ActiveDirectory'

<#
Expand Down Expand Up @@ -33,7 +37,8 @@ $script:psModuleName = 'ActiveDirectory'
Used Functions:
Name | Module
------------------------------|--------------------------
Assert-Module | ActiveDirectoryDsc.Common
Assert-Module | DscResource.Common
New-CimCredentialInstance | ActiveDirectoryDsc.Common
Get-ADForest | ActiveDirectory
Get-ADObject | ActiveDirectory
Get-ADRootDSE | ActiveDirectory
Expand Down Expand Up @@ -148,7 +153,7 @@ function Get-TargetResource
Name | Module
------------------------------|--------------------------
Assert-MemberParameters | ActiveDirectoryDsc.Common
Assert-Module | ActiveDirectoryDsc.Common
Assert-Module | DscResource.Common
Test-Members | ActiveDirectoryDsc.Common
#>
function Test-TargetResource
Expand Down Expand Up @@ -310,9 +315,9 @@ function Test-TargetResource
Used Functions:
Name | Module
------------------------------|--------------------------
Assert-Module | ActiveDirectoryDsc.Common
Assert-Module | DscResource.Common
New-InvalidOperationException | DscResource.Common
Get-ADRootDSE | ActiveDirectory
New-InvalidOperationException | ActiveDirectoryDsc.Common
Set-ADForest | ActiveDirectory
Set-ODObject | ActiveDirectory
#>
Expand Down
13 changes: 8 additions & 5 deletions source/DSCResources/MSFT_ADGroup/MSFT_ADGroup.psm1
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADGroup'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
.SYNOPSIS
Expand Down
13 changes: 8 additions & 5 deletions source/DSCResources/MSFT_ADKDSKey/MSFT_ADKDSKey.psm1
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADKDSKey'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
$script:resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$script:modulesFolderPath = Join-Path -Path $script:resourceModulePath -ChildPath 'Modules'
$resourceModulePath = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$modulesFolderPath = Join-Path -Path $resourceModulePath -ChildPath 'Modules'

$script:localizationModulePath = Join-Path -Path $script:modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name (Join-Path -Path $script:localizationModulePath -ChildPath 'ActiveDirectoryDsc.Common.psm1')
$aDCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'ActiveDirectoryDsc.Common'
Import-Module -Name $aDCommonModulePath

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_ADManagedServiceAccount'
$dscResourceCommonModulePath = Join-Path -Path $modulesFolderPath -ChildPath 'DscResource.Common'
Import-Module -Name $dscResourceCommonModulePath

$script:localizedData = Get-LocalizedData -DefaultUICulture 'en-US'

$script:errorCodeKdsRootKeyNotFound = -2146893811

Expand Down Expand Up @@ -39,10 +42,10 @@ $script:errorCodeKdsRootKeyNotFound = -2146893811
------------------------------|--------------------------
Get-ADObject | ActiveDirectory
Get-ADServiceAccount | ActiveDirectory
Assert-Module | ActiveDirectoryDsc.Common
Assert-Module | DscResource.Common
New-InvalidOperationException | DscResource.Common
Get-ADCommonParameters | ActiveDirectoryDsc.Common
Get-ADObjectParentDN | ActiveDirectoryDsc.Common
New-InvalidOperationException | ActiveDirectoryDsc.Common
#>
function Get-TargetResource
{
Expand Down Expand Up @@ -426,7 +429,7 @@ function Test-TargetResource
Compare-ResourcePropertyState | ActiveDirectoryDsc.Common
Get-ADCommonParameters | ActiveDirectoryDsc.Common
Get-DomainName | ActiveDirectoryDsc.Common
New-InvalidOperationException | ActiveDirectoryDsc.Common
New-InvalidOperationException | DscResource.Common
#>

function Set-TargetResource
Expand Down
Loading

0 comments on commit d648714

Please sign in to comment.