Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xActiveDirectory: Cleanup code #326

Merged
merged 29 commits into from
Jun 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c165632
Remove semicolon from rows
johlju Jun 7, 2019
7d2ed6b
Update CHANGELOG.md
johlju Jun 7, 2019
8aff5a7
Migrate tests to Pester syntax v4.x (issue #322)
johlju Jun 7, 2019
d4b25a0
Removed `-MockWith {}` in unit tests.
johlju Jun 7, 2019
93fb0d2
Changes to xADRecycleBin
johlju Jun 7, 2019
6b76655
Changes to xADRecycleBin
johlju Jun 7, 2019
75d0b93
Changes to xADDomainDefaultPasswordPolicy
johlju Jun 7, 2019
5a0df70
Changes to xADDomainTrust
johlju Jun 7, 2019
0530c55
Changes to xADForestProperties
johlju Jun 7, 2019
9e9bcac
Changes to xADGroup
johlju Jun 7, 2019
8560659
Changes to xADOrganizationalUnit
johlju Jun 7, 2019
a4d033a
Changes to xADUser
johlju Jun 7, 2019
028f8ac
Changes to xWaitForADDomain
johlju Jun 7, 2019
334ce72
Add VSCode code formatting
johlju Jun 7, 2019
f63b18e
Add verbose in xADRecycleBin
johlju Jun 7, 2019
d6ea286
Fix typo in xADObjectPermissionEntry.Tests
johlju Jun 7, 2019
09e41f1
Typ in xWaitForADDomain.Tests
johlju Jun 7, 2019
e3646a8
Fix CHANGELOG.md after rebase
johlju Jun 13, 2019
1c01c35
Fix full stop
johlju Jun 15, 2019
c0f0fe4
Fix comment that did not match style guideline
johlju Jun 15, 2019
b968759
Fix if-blocks
johlju Jun 15, 2019
d06e883
Fix named parameters on New-Object
johlju Jun 15, 2019
22b6b62
Fix named parameters on Where-Object
johlju Jun 15, 2019
08c7704
Remove semi-colon from missed file
johlju Jun 15, 2019
0b984f6
Fixed missed comment block
johlju Jun 15, 2019
b1b6147
Remove BOM from file
johlju Jun 15, 2019
b638593
Fix review comments at r3
johlju Jun 15, 2019
006e836
Fix Pester syntax in recent merges
johlju Jun 15, 2019
acc3c78
Update CHANGELOG.md
johlju Jun 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 46 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,36 @@
- Convert-PropertyMapToObjectProperties
- Compare-ResourcePropertyState
- Test-DscPropertyState
- Move the examples in the README.md to Examples folder
- Fix Script Analyzer rule failures
- Move the examples in the README.md to Examples folder.
- Fix Script Analyzer rule failures.
- Opt-in to the following DSC Resource Common Meta Tests:
- Common Tests - Custom Script Analyzer Rules
- Common Tests - Required Script Analyzer Rules
- Common Tests - Flagged Script Analyzer Rules
- Common Tests - Validate Module Files ([Issue #282](https://github.com/PowerShell/xActiveDirectory/issues/282))
- Common Tests - Validate Script Files ([Issue #283](https://github.com/PowerShell/xActiveDirectory/issues/283))
- Common Tests - Relative Path Length ([Issue #284](https://github.com/PowerShell/xActiveDirectory/issues/284))
- Common Tests - Validate Markdown Links ([Issue #280](https://github.com/PowerShell/xActiveDirectory/issues/280))
- Common Tests - Validate Localization ([Issue #281](https://github.com/PowerShell/xActiveDirectory/issues/281))
- Common Tests - Validate Example Files ([Issue #279](https://github.com/PowerShell/xActiveDirectory/issues/279))
- Common Tests - Validate Example Files To Be Published ([Issue #311](https://github.com/PowerShell/xActiveDirectory/issues/311))
- Move resource descriptions to Wiki using auto-documentation ([Issue #289](https://github.com/PowerShell/xActiveDirectory/issues/289))
- Common Tests - Validate Module Files ([issue #282](https://github.com/PowerShell/xActiveDirectory/issues/282))
- Common Tests - Validate Script Files ([issue #283](https://github.com/PowerShell/xActiveDirectory/issues/283))
- Common Tests - Relative Path Length ([issue #284](https://github.com/PowerShell/xActiveDirectory/issues/284))
- Common Tests - Validate Markdown Links ([issue #280](https://github.com/PowerShell/xActiveDirectory/issues/280))
- Common Tests - Validate Localization ([issue #281](https://github.com/PowerShell/xActiveDirectory/issues/281))
- Common Tests - Validate Example Files ([issue #279](https://github.com/PowerShell/xActiveDirectory/issues/279))
- Common Tests - Validate Example Files To Be Published ([issue #311](https://github.com/PowerShell/xActiveDirectory/issues/311))
- Move resource descriptions to Wiki using auto-documentation ([issue #289](https://github.com/PowerShell/xActiveDirectory/issues/289))
- Move helper functions from MSFT_xADCommon to the module
xActiveDirectory.Common ([issue #288](https://github.com/PowerShell/xActiveDirectory/issues/288))
xActiveDirectory.Common ([issue #288](https://github.com/PowerShell/xActiveDirectory/issues/288)).
- Removed helper function `Test-ADDomain` since it was not used. The
helper function had design flaws too.
- Now the helper function `Test-Members` outputs all the members that
are not in desired state when verbose output is enabled.
- Update all unit tests to latest unit test template.
- Deleted the obsolete xActiveDirectory_TechNetDocumentation.html file
- Deleted the obsolete xActiveDirectory_TechNetDocumentation.html file.
- Added new resource xADObjectEnabledState. This resource should be
used to enforce the `Enabled` property of computer accounts. This
resource replaces the deprecated `Enabled` property in the resource
xADComputer.
- Cleanup of code
- Removed semicolon throughout where it is not needed.
- Migrate tests to Pester syntax v4.x ([issue #322](https://github.com/PowerShell/xActiveDirectory/issues/322)).
- Removed `-MockWith {}` in unit tests.
- Changes to xADComputer
- Refactored the resource and the unit tests.
- BREAKING CHANGE: The `Enabled` property is **DEPRECATED** and is no
Expand All @@ -49,50 +53,72 @@
if the computer account is created enabled or disabled.
- Moved examples from the README.md to separate example files in the
Examples folder.
- Fix the RestoreFromRecycleBin Description
- Fix unnecessary cast in `Test-TargetResource` ([Issue #295](https://github.com/PowerShell/xActiveDirectory/issues/295))
- Fix the RestoreFromRecycleBin description.
- Fix unnecessary cast in `Test-TargetResource` ([issue #295](https://github.com/PowerShell/xActiveDirectory/issues/295)).
- Changes to xADGroup
- Change the description of the property RestoreFromRecycleBin.
- Code cleanup.
- Changes to xADObjectPermissionEntry
- Change the description of the property IdentityReference.
- Fix failure when applied in the same configuration as xADDomain.
- Localize and Improve verbose messaging.
- Code cleanup.
- Changes to xADOrganizationalUnit
- Change the description of the property RestoreFromRecycleBin.
- Code cleanup.
- Changes to xADUser
- Change the description of the property RestoreFromRecycleBin.
- Added ServicePrincipalNames property ([issue #153](https://github.com/PowerShell/xActiveDirectory/issues/153)).
- Added ChangePasswordAtLogon property ([issue #246](https://github.com/PowerShell/xActiveDirectory/issues/246)).
- Code cleanup.
- Changes to xADDomainController
- Change the `#Requires` statement in the Examples to require the correct
module.
- Suppressing the Script Analyzer rule `PSAvoidGlobalVars` since the
resource is using the `$global:DSCMachineStatus` variable to trigger
a reboot.
- Code cleanup.
- Changes to xADDomain
- Suppressing the Script Analyzer rule `PSAvoidGlobalVars` since the
resource is using the `$global:DSCMachineStatus` variable to trigger
a reboot.
- Code cleanup.
- Changes to xADDomainTrust
- Replaced New-TerminatingError with Standard Function.
- Code cleanup.
- Changes to xWaitForADDomain
- Suppressing the Script Analyzer rule `PSAvoidGlobalVars` since the
resource is using the `$global:DSCMachineStatus` variable to trigger
a reboot.
- Changes to xADObjectPermissionEntry
- Fix failure when applied in the same configuration as xADDomain
- Localize and Improve verbose messaging
- Added missing property schema descriptions ([issue #369](https://github.com/PowerShell/xActiveDirectory/issues/369)).
- Code cleanup.
- Changes to xADRecycleBin
- Remove unneeded example and resource designer files.
- Added missing property schema descriptions ([issue #368](https://github.com/PowerShell/xActiveDirectory/issues/368)).
- Code cleanup.
- It now set back the `$ErrorActionPreference` that was set prior to
setting it to `'Stop'`.
- Changes to xADReplicationSiteLink
- Fix ADIdentityNotFoundException When Creating a New Site Link.
- Fix ADIdentityNotFoundException when creating a new site link.
- Code cleanup.
- Changes to xADReplicationSubnet
- Remove `{ *Present* | Absent }` from the property schema descriptions
which were causing corruption in the Wiki documentation.
- Changes to xADServicePrincipalNames
- Remove `{ *Present* | Absent }` from the property schema descriptions
which were causing corruption in the Wiki documentation.
- Changes to xWaitForADDomain
- Added missing property schema descriptions ([issue #369](https://github.com/PowerShell/xActiveDirectory/issues/369)).
- Changes to xADDomainDefaultPasswordPolicy
- Code cleanup.
- Changes to xADForestProperties
- Minor style cleanup.
- Changes to xADReplicationSubnet
- Code cleanup.
- Changes to xADKDSKey
- Code cleanup.
- Changes to xADManagedServiceAccount
- Code cleanup.
- Changes to xADServicePrincipalName
- Code cleanup.

## 2.26.0.0

Expand Down
71 changes: 51 additions & 20 deletions DSCResources/MSFT_xADComputer/MSFT_xADComputer.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ function Get-TargetResource
written with Set-ADComputer the property name must be
'ServicePrincipalName'. This difference is handled here.
#>
$computerObjectProperties = @($computerObjectProperties | Where-Object -FilterScript {
$_ -ne 'ServicePrincipalName'
})
$computerObjectProperties = @($computerObjectProperties |
Where-Object -FilterScript {
$_ -ne 'ServicePrincipalName'
})

$computerObjectProperties += @('ServicePrincipalNames')

Expand Down Expand Up @@ -413,12 +414,13 @@ function Test-TargetResource
}

# Need the @() around this to get a new array to enumerate.
@($getTargetResourceParameters.Keys) | ForEach-Object {
if (-not $PSBoundParameters.ContainsKey($_))
{
$getTargetResourceParameters.Remove($_)
@($getTargetResourceParameters.Keys) |
ForEach-Object {
if (-not $PSBoundParameters.ContainsKey($_))
{
$getTargetResourceParameters.Remove($_)
}
}
}

$getTargetResourceResult = Get-TargetResource @getTargetResourceParameters

Expand Down Expand Up @@ -668,12 +670,13 @@ function Set-TargetResource
}

# Need the @() around this to get a new array to enumerate.
@($getTargetResourceParameters.Keys) | ForEach-Object {
if (-not $PSBoundParameters.ContainsKey($_))
{
$getTargetResourceParameters.Remove($_)
@($getTargetResourceParameters.Keys) |
ForEach-Object {
if (-not $PSBoundParameters.ContainsKey($_))
{
$getTargetResourceParameters.Remove($_)
}
}
}

$getTargetResourceResult = Get-TargetResource @getTargetResourceParameters

Expand Down Expand Up @@ -880,15 +883,17 @@ function Set-TargetResource
$removeComputerProperties = @{ }

# Get all properties, other than Path, that is not in desired state.
$propertiesNotInDesiredState = $compareTargetResourceStateResult | Where-Object -FilterScript {
$_.ParameterName -ne 'Path' -and -not $_.InDesiredState
}
$propertiesNotInDesiredState = $compareTargetResourceStateResult |
Where-Object -FilterScript {
$_.ParameterName -ne 'Path' -and -not $_.InDesiredState
}

foreach ($property in $propertiesNotInDesiredState)
{
$computerAccountPropertyName = ($script:computerObjectPropertyMap | Where-Object -FilterScript {
$_.ParameterName -eq $property.ParameterName
}).PropertyName
$computerAccountPropertyName = ($script:computerObjectPropertyMap |
Where-Object -FilterScript {
$_.ParameterName -eq $property.ParameterName
}).PropertyName

if (-not $computerAccountPropertyName)
{
Expand Down Expand Up @@ -946,10 +951,36 @@ function Set-TargetResource
$removeADComputerParameters = Get-ADCommonParameters @PSBoundParameters
$removeADComputerParameters['Confirm'] = $false

Remove-ADComputer @removeADComputerParameters | Out-Null
Remove-ADComputer @removeADComputerParameters |
Out-Null
}
}

<#
.SYNOPSIS
This is a wrapper for Set-ADComputer.

.PARAMETER Parameters
A hash table containing all parameters that will be passed trough to
Set-ADComputer.

.NOTES
This is needed because of how Pester is unable to handle mocking the
cmdlet Set-ADComputer.
#>
function Set-DscADComputer
{
param
(
[Parameter(Mandatory = $true)]
[System.Collections.Hashtable]
$Parameters
)

Set-ADComputer @Parameters |
Out-Null
}

<#
.SYNOPSIS
This evaluates the service principal names current state against the
Expand Down
Loading