Skip to content

Commit

Permalink
Merge pull request #129 from PowerShell/dev
Browse files Browse the repository at this point in the history
Merging release pull request
  • Loading branch information
kwirkykat authored Dec 14, 2016
2 parents 2a56926 + 57f4850 commit ea9e6ff
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,15 @@ function Get-TargetResource
if ($dc.Domain -eq $DomainName)
{
Write-Verbose -Message "Current node '$($dc.Name)' is already a domain controller for domain '$($dc.Domain)'."
$returnValue.Ensure = $true
$returnValue.SiteName = $dc.Site

$serviceNTDS = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\NTDS\Parameters'
$serviceNETLOGON = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters'

$returnValue.Ensure = $true
$returnValue.DatabasePath = $serviceNTDS.'DSA Working Directory'
$returnValue.LogPath = $serviceNTDS.'Database log files path'
$returnValue.SysvolPath = $serviceNETLOGON.SysVol -replace '\\sysvol$', ''
$returnValue.SiteName = $dc.Site
}
}
catch
Expand Down Expand Up @@ -140,7 +147,7 @@ function Set-TargetResource
elseif ($targetResource.Ensure)
{
## Node is a domain controller. We check if other properties are in desired state
if ($targetResource.SiteName -ne $SiteName)
if ($PSBoundParameters["SiteName"] -and $targetResource.SiteName -ne $SiteName)
{
## DC is not in correct site. Move it.
Write-Verbose "Moving Domain Controller from '$($targetResource.SiteName)' to '$SiteName'"
Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ These DSC Resources allow you to configure new domains, child domains, and high
* **ParentDomainName**: Fully qualified name of the parent domain (optional).
* **DomainAdministratorCredential**: Credentials used to query for domain existence.
* __Note: These are NOT used during domain creation.__
(AD sets the localadmin credentials as new domain administrator credentials during setup.)
(AD sets the local admin credentials as new domain administrator credentials during setup.)
* **SafemodeAdministratorPassword**: Password for the administrator account when the computer is started in Safe Mode.
* **DnsDelegationCredential**: Credential used for creating DNS delegation (optional).
* **DomainNetBIOSName**: Specifies the NetBIOS name for the new domain (optional).
Expand Down Expand Up @@ -64,7 +64,7 @@ These DSC Resources allow you to configure new domains, child domains, and high
* To be compatible with older operating systems, create a SAM account name that is 20 characters or less.
* Once created, the user's SamAccountName and CN cannot be changed.
* **Password**: Password value for the user account.
* _If the account is enabled (default behaviour) you must specifiy a password._
* _If the account is enabled (default behaviour) you must specify a password._
* _You must ensure that the password meets the domain's complexity requirements._
* **Ensure**: Specifies whether the given user is present or absent (optional).
* If not specified, this value defaults to Present.
Expand All @@ -74,7 +74,7 @@ These DSC Resources allow you to configure new domains, child domains, and high
* This is only required if not executing the task on a domain controller or using the -DomainController parameter.
* **CommonName**: Specifies the user's CN of the user account (optional).
* If not specified, this defaults to the ___UserName___ value.
* **UserPrincipalName**: Each user account has a user principal name (UPN) in the format [user]@[DNS-domain-name] (optional).
* **UserPrincipalName**: Each user account has a user principal name (UPN) in the format [user]@[DNS-domain-name] (optional).
* **DisplayName**: Specifies the display name of the user object (optional).
* **Path**: (optional).
* **GivenName**: Specifies the user's first or given name (optional).
Expand Down Expand Up @@ -126,8 +126,8 @@ These DSC Resources allow you to configure new domains, child domains, and high
### **xWaitForADDomain**

* **DomainName**: Name of the remote domain.
* **RetryIntervalSec**: Interval to check for the domain's existance.
* **RetryCount**: Maximum number of retries to check for the domain's existance.
* **RetryIntervalSec**: Interval to check for the domain's existence.
* **RetryCount**: Maximum number of retries to check for the domain's existence.

### **xADDomainTrust**

Expand Down Expand Up @@ -163,16 +163,16 @@ The xADGroup DSC resource will manage groups within Active Directory.
* **Description**: Specifies a description of the group object (optional).
* **DisplayName**: Specifies the display name of the group object (optional).
* **Members**: Specifies the explicit AD objects that should comprise the group membership (optional).
* If not specified, no group membershup changes are made.
* If not specified, no group membership changes are made.
* If specified, all undefined group members will be removed the AD group.
* This property cannot be specified with either 'MembersToInclude' or 'MembersToExclude'.
* **MembersToInclude**: Specifies AD objects that must be in the group (optional).
* If not specified, no group membershup changes are made.
* If not specified, no group membership changes are made.
* If specified, only the specified members are added to the group.
* If specified, no users are removed from the group using this parameter.
* This property cannot be specified with the 'Members' parameter.
* **MembersToExclude**: Specifies AD objects that _must not_ be in the group (optional).
* If not specified, no group membershup changes are made.
* If not specified, no group membership changes are made.
* If specified, only those specified are removed from the group.
* If specified, no users are added to the group using this parameter.
* This property cannot be specified with the 'Members' parameter.
Expand Down Expand Up @@ -244,8 +244,12 @@ Setting an ODJ Request file path for a configuration that creates a computer acc

### Unreleased

### 2.15.0.0
* xAdDomainController: Fixes SiteName being required field.

### 2.14.0.0
* xADDomainController: Adds Site option.
* xADDomainController: Populate values for DatabasePath, LogPath and SysvolPath during Get-TargetResource.

### 2.13.0.0
* Converted AppVeyor.yml to pull Pester from PSGallery instead of Chocolatey
Expand Down
71 changes: 59 additions & 12 deletions Tests/Unit/MSFT_xADDomainController.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ $TestEnvironment = Initialize-TestEnvironment `
try
{
#region Pester Test Initialization
$correctSiteName = 'PresentSite'
$incorrectSiteName = 'IncorrectSite'
$correctDomainName = 'present.com'
$correctDomainName = 'present.com'
$testAdminCredential = [System.Management.Automation.PSCredential]::Empty
$correctDatabasePath = 'C:\Windows\NTDS'
$correctLogPath = 'C:\Windows\NTDS'
$correctSysvolPath = 'C:\Windows\SYSVOL'
$correctSiteName = 'PresentSite'
$incorrectSiteName = 'IncorrectSite'

$testDefaultParams = @{
DomainAdministratorCredential = $testAdminCredential
Expand Down Expand Up @@ -56,17 +59,43 @@ try

#region Function Get-TargetResource
Describe -Tag 'xADDomainController' "$($Script:DSCResourceName)\Get-TargetResource" {
It 'Returns current "SiteName"' {
Mock Get-ADDomain { return $true } @commonMockParams
Mock Get-ADDomainController {
return $stubDomainController = @{
Site = 'PresentSite'
Domain = 'present.com'
}
} @commonMockParams

$result = Get-TargetResource @testDefaultParams -DomainName $correctDomainName -SiteName $correctSiteName
Mock Get-ADDomain { return $true } @commonMockParams
Mock Get-ADDomainController {
return $stubDomainController = @{
Site = 'PresentSite'
Domain = 'present.com'
}
} @commonMockParams
Mock Get-ItemProperty -ParameterFilter { $Path -eq 'HKLM:\SYSTEM\CurrentControlSet\Services\NTDS\Parameters' } {
return @{
'Database log files path' = 'C:\Windows\NTDS'
'DSA Working Directory' = 'C:\Windows\NTDS'
}
} @commonMockParams
Mock Get-ItemProperty -ParameterFilter { $Path -eq 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters' } {
return @{
'SysVol' = 'C:\Windows\SYSVOL\sysvol'
}
} @commonMockParams

It 'Returns current "DatabasePath"' {
$result = Get-TargetResource @testDefaultParams -DomainName $correctDomainName
$result.DatabasePath | Should Be $correctDatabasePath
}

It 'Returns current "LogPath"' {
$result = Get-TargetResource @testDefaultParams -DomainName $correctDomainName
$result.LogPath | Should Be $correctLogPath
}

It 'Returns current "SysvolPath"' {
$result = Get-TargetResource @testDefaultParams -DomainName $correctDomainName
$result.SysvolPath | Should Be $correctSysvolPath
}

It 'Returns current "SiteName"' {
$result = Get-TargetResource @testDefaultParams -DomainName $correctDomainName
$result.SiteName | Should Be $correctSiteName
}
}
Expand Down Expand Up @@ -98,6 +127,8 @@ try
Mock Get-ADDomain { return $true }
Mock Get-ADDomainController { return $stubDomainController }
Mock Test-ADReplicationSite { return $true }
Mock Get-ItemProperty { return @{} }

$result = Test-TargetResource @testDefaultParams -DomainName $correctDomainName -SiteName $correctSiteName

$result | Should Be $false
Expand All @@ -113,6 +144,7 @@ try
Mock Get-ADDomain { return $true }
Mock Get-ADDomainController { return $stubDomainController }
Mock Test-ADReplicationSite { return $true }
Mock Get-ItemProperty { return @{} }

$result = Test-TargetResource @testDefaultParams -DomainName $correctDomainName -SiteName $correctSiteName

Expand Down Expand Up @@ -185,6 +217,21 @@ try

Assert-MockCalled Move-ADDirectoryServer -Times 0 @commonAssertParams
}

It 'Does not call "Move-ADDirectoryServer" when "SiteName" is not specified' {
Mock Get-TargetResource {
return $stubTargetResource = @{
Ensure = $true
SiteName = 'PresentSite'
}
} @commonMockParams

Mock Move-ADDirectoryServer {} @commonMockParams

Set-TargetResource @testDefaultParams -DomainName $correctDomainName

Assert-MockCalled Move-ADDirectoryServer -Times 0 @commonAssertParams
}
}
#endregion
}
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#---------------------------------#
# environment configuration #
#---------------------------------#
version: 2.14.{build}.0
version: 2.15.{build}.0
install:
- git clone https://github.com/PowerShell/DscResource.Tests
- ps: |
Expand Down Expand Up @@ -47,7 +47,7 @@ deploy_script:
# Creating project artifact
$stagingDirectory = (Resolve-Path ..).Path
$manifest = Join-Path $pwd "xActiveDirectory.psd1"
(Get-Content $manifest -Raw).Replace("2.14.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest
(Get-Content $manifest -Raw).Replace("2.15.0.0", $env:APPVEYOR_BUILD_VERSION) | Out-File $manifest
$zipFilePath = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip"
Add-Type -assemblyname System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory($pwd, $zipFilePath)
Expand Down
5 changes: 3 additions & 2 deletions xActiveDirectory.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
# Version number of this module.
ModuleVersion = '2.14.0.0'
ModuleVersion = '2.15.0.0'

# ID used to uniquely identify this module
GUID = '9FECD4F6-8F02-4707-99B3-539E940E9FF5'
Expand Down Expand Up @@ -49,7 +49,7 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* xADDomainController: Adds Site option.
ReleaseNotes = '* xAdDomainController: Fixes SiteName being required field.
'

Expand All @@ -61,3 +61,4 @@ PrivateData = @{




0 comments on commit ea9e6ff

Please sign in to comment.