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

Release of version 3.13.0.0 of xPSDesiredStateConfiguration #193

Merged
merged 64 commits into from
Aug 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5c64c86
* xGroup: Fix Verbose output in Get-MembersAsPrincipals function.
PlagueHO Jul 3, 2016
2b90ff0
Merge pull request #173 from PlagueHO/Fix-139/xGroup-Invoke-DSCResour…
kwirkykat Jul 5, 2016
d1f1ec3
Moving xPackage examples and tests and merging with in-box.
Jul 5, 2016
9c519d6
Removing os specification and chocolately from appveyor.yml.
Jul 5, 2016
3227076
Updating README.
Jul 5, 2016
5b035ba
Removing unnecessary location changes.
Jul 5, 2016
9c4e858
Merge pull request #174 from PowerShell/EditAppveyorFile
kwirkykat Jul 6, 2016
84f63ed
Updating xPackage tests.
kwirkykat Jul 7, 2016
911c72c
Merging Package and updating tests.
Jul 11, 2016
5eb7c4c
Merge branch 'dev' into MergePackageResource
Jul 11, 2016
bee8f39
Updating README.
Jul 11, 2016
044c3e4
Updating mof to match resource schema.
Jul 11, 2016
b71c21c
Updating xPackage schema in README.
Jul 11, 2016
ea13bc5
Reverting ReturnCode back to a UInt32 to match schema.
Jul 11, 2016
371691a
Converting mof from Unicode to ASCII.
Jul 11, 2016
6ec5df8
Replacing error throw with Should block in tests.
Jul 12, 2016
eb00366
Fixing variables that Pester doesn't like.
Jul 12, 2016
5fe36ab
Fixing messed up quote.
Jul 12, 2016
4dfabfe
Adding test environment cleanup and fixing BatchSize warning.
Jul 12, 2016
40b5732
Removing extra xPackage test and suppressing Get-CimInstance error.
Jul 12, 2016
c2c208f
Removing use of Win32_Prodcut in attempt to reduce test time.
Jul 12, 2016
f343406
Fixed a logic bug for MembersToInclude/Exclude.
Jul 12, 2016
976075f
Adding a few more Set-TargetResource tests.
Jul 12, 2016
a095cd6
Replacing some other changes that got overwritten.
Jul 12, 2016
adc3d6e
Adding back newline at end of file.
Jul 12, 2016
0571016
Starting to merge Process.
Jul 13, 2016
ede6107
Updating HQRM plan progress.
Jul 13, 2016
a1b69ca
Merge pull request #176 from kwirkykat/MergePackageResource
kwirkykat Jul 13, 2016
f2e9137
Fixing merge conflict in README.
Jul 13, 2016
e93ea2e
Merge pull request #177 from kwirkykat/FixGroup
kwirkykat Jul 13, 2016
1e1589d
Merge branch 'dev' into MergeProcessResource
Jul 13, 2016
0631396
Updating xProcess and tests.
Jul 21, 2016
554f663
Replacing group.Clear() and adding empty group test.
Jul 21, 2016
c68bbd3
Fixing bugs and adding integration tests.
Jul 22, 2016
49fc7e0
Removing extra code.
Jul 22, 2016
5560849
Adding newline at end of file.
Jul 22, 2016
f69243d
Switching test environment to Unit to fix module location for now.
Jul 22, 2016
4e1065b
Switched wrong test.
Jul 22, 2016
5f3c171
Removing InModuleScope and switching test environment back to Integra…
Jul 22, 2016
90f6430
Adding more bug fixes and updating README.
Jul 25, 2016
3f47e6b
Merge pull request #182 from kwirkykat/FixGroupResource
kwirkykat Jul 27, 2016
8117292
Updating xProcess resource and tests.
Jul 30, 2016
1f4d054
Merge branch 'dev' into MergeProcessResource
Jul 30, 2016
06371a4
Updating README and HQRM plan.
Jul 30, 2016
71336d5
Removing extra function from CommonResourceHelper.
Jul 30, 2016
d539b0f
Suppressing PSSA rule in tests.
Aug 1, 2016
0a30ab1
Change parameter validation of Description to ValidateNotNull
Aug 2, 2016
516e3c7
Remove invalid parameters
Aug 2, 2016
7297810
Remove obsolete configuration parameters
Aug 2, 2016
f04ddc8
Convert Path parameter to single string
Aug 2, 2016
cfc6920
Update Unreleased section of README.md
Aug 2, 2016
c210c99
Merge pull request #185 from Dan1el42/issue-179
kwirkykat Aug 2, 2016
fe90627
Merge pull request #186 from Dan1el42/issue-181
kwirkykat Aug 2, 2016
fa7252c
Merging with dev.
Aug 2, 2016
e715a79
Merge pull request #184 from kwirkykat/MergeProcessResource
kwirkykat Aug 2, 2016
61002f6
Adding registry parameters back into xPackage.
Aug 3, 2016
7ac3519
Replace alias ipmo with full cmdlet name
Aug 4, 2016
0101c15
Merge pull request #188 from Dan1el42/issue-183
BerheAbrha Aug 8, 2016
20f934e
Adding tests for registry parameters and fixing xPackage for new params.
Aug 9, 2016
b0c5079
Updating README.
Aug 9, 2016
ffc4033
Adding an integration test for xPackage.
Aug 9, 2016
76c6496
Removing force on import in common test helper and converting xPackag…
Aug 9, 2016
9f25544
Merge pull request #192 from kwirkykat/FixPackageResource
kwirkykat Aug 10, 2016
8d06d2b
Releasing version 3.13.0.0
Aug 10, 2016
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
4 changes: 2 additions & 2 deletions DSCResources/CommonResourceHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ function New-InvalidOperationException

Export-ModuleMember -Function `
Test-IsNanoServer, `
Throw-InvalidArgumentException, `
Throw-TerminatingError
New-InvalidArgumentException, `
New-InvalidOperationException
130 changes: 100 additions & 30 deletions DSCResources/MSFT_xGroupResource/MSFT_xGroupResource.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,18 @@ function Set-TargetResourceOnFullSKU

if ($Ensure -eq 'Present')
{
$actualMembersAsPrincipals = $null

if ($groupOriginallyExists)
{
$disposables.Add($group) | Out-Null
$whatIfShouldProcess = $pscmdlet.ShouldProcess(($LocalizedData.GroupWithName -f $GroupName), $LocalizedData.SetOperation)

$actualMembersAsPrincipals = @( Get-MembersAsPrincipals `
-Group $group `
-PrincipalContexts $principalContexts `
-Disposables $disposables `
-Credential $Credential )
}
else
{
Expand Down Expand Up @@ -433,14 +441,47 @@ function Set-TargetResourceOnFullSKU
-Disposables $disposables `
-Credential $Credential

if ($membersAsPrincipals.Length -gt 0)
if ($membersAsPrincipals.Count -gt 0)
{
$group.Members.Clear()
if ($null -ne $actualMembersAsPrincipals -and $actualMembersAsPrincipals.Count -gt 0)
{
$membersToAdd = @()
$membersToRemove = @()

# Set the members of the group
if (Add-GroupMembers -Group $group -MembersAsPrincipals $membersAsPrincipals)
foreach ($membersAsPrincipal in $membersAsPrincipals)
{
if ($actualMembersAsPrincipals -notcontains $membersAsPrincipal)
{
$membersToAdd += $membersAsPrincipal
}
}

foreach ($actualMembersAsPrincipal in $actualMembersAsPrincipals)
{
if ($membersAsPrincipals -notcontains $actualMembersAsPrincipal)
{
$membersToRemove += $actualMembersAsPrincipal
}
}

# Set the members of the group
if (Add-GroupMembers -Group $group -MembersAsPrincipals $membersToAdd)
{
$saveChanges = $true
}

if (Remove-GroupMembers -Group $group -MembersAsPrincipals $membersToRemove)
{
$saveChanges = $true
}
}
else
{
$saveChanges = $true
# Set the members of the group
if (Add-GroupMembers -Group $group -MembersAsPrincipals $membersAsPrincipals)
{
$saveChanges = $true
}
}
}
else
Expand Down Expand Up @@ -495,21 +536,21 @@ function Set-TargetResourceOnFullSKU
}
}

if ($membersToIncludeAsPrincipals.Length -eq 0 -and $membersToExcludeAsPrincipals.Length -eq 0)
if ($membersToIncludeAsPrincipals.Count -eq 0 -and $membersToExcludeAsPrincipals.Count -eq 0)
{
New-InvalidArgumentException -ArgumentName 'MembersToInclude and MembersToExclude' -Message ($LocalizedData.IncludeAndExcludeAreEmpty)
}
}

if ($null -ne $membersToExcludeAsPrincipals -and $membersToExcludeAsPrincipals.Length -eq 0)
if ($null -ne $membersToExcludeAsPrincipals -and $membersToExcludeAsPrincipals.Count -gt 0)
{
if (Remove-GroupMembers -Group $group -MembersAsPrincipals $membersToExcludeAsPrincipals)
{
$saveChanges = $true
}
}

if ($null -ne $membersToIncludeAsPrincipals -and $membersToIncludeAsPrincipals.Length -eq 0)
if ($null -ne $membersToIncludeAsPrincipals -and $membersToIncludeAsPrincipals.Count -gt 0)
{
if (Add-GroupMembers -Group $group -MembersAsPrincipals $membersToIncludeAsPrincipals)
{
Expand Down Expand Up @@ -651,6 +692,15 @@ function Test-TargetResourceOnFullSKU
return ($Ensure -eq 'Absent')
}

if ($null -ne $group.Members)
{
$actualGroupMembers = @($group.Members)
}
else
{
$actualGroupMembers = $null
}

$disposables.Add($group) | Out-Null
Write-Verbose -Message ($LocalizedData.GroupExists -f $GroupName)

Expand Down Expand Up @@ -686,31 +736,31 @@ function Test-TargetResourceOnFullSKU

if ($Members.Count -eq 0)
{
return ($group.Members.Count -eq 0)
return ($null -eq $actualGroupMembers -or $actualGroupMembers.Count -eq 0)
}
else
{
# Remove duplicate names as strings.
$Members = @( Remove-DuplicateMembers -Members $Members )

# Resolve the names to actual principal objects.
$expectedMembersAsPrincipals = ConvertTo-Principals `
$expectedMembersAsPrincipals = @( ConvertTo-Principals `
-MemberNames $Members `
-PrincipalContexts $principalContexts `
-Disposables $disposables `
-Credential $Credential
-Credential $Credential )

if ($expectedMembersAsPrincipals.Length -ne $group.Members.Count)
if ($expectedMembersAsPrincipals.Count -ne $actualGroupMembers.Count)
{
Write-Verbose -Message ($LocalizedData.MembersNumberMismatch -f 'Members', $expectedMembersAsPrincipals.Length, $group.Members.Count)
Write-Verbose -Message ($LocalizedData.MembersNumberMismatch -f 'Members', $expectedMembersAsPrincipals.Count, $actualGroupMembers.Count)
return $false
}

$actualMembersAsPrincipals = Get-MembersAsPrincipals `
$actualMembersAsPrincipals = @( Get-MembersAsPrincipals `
-Group $group `
-PrincipalContexts $principalContexts `
-Disposables $disposables `
-Credential $Credential
-Credential $Credential )

# Compare the two member lists.
foreach ($expectedMemberAsPrincipal in $expectedMembersAsPrincipals)
Expand All @@ -723,13 +773,13 @@ function Test-TargetResourceOnFullSKU
}
}
}
else
elseif ($PSBoundParameters.ContainsKey('MembersToInclude') -or $PSBoundParameters.ContainsKey('MembersToExclude'))
{
$actualMembersAsPrincipals = Get-MembersAsPrincipals `
$actualMembersAsPrincipals = @( Get-MembersAsPrincipals `
-Group $group `
-PrincipalContexts $principalContexts `
-Disposables $disposables `
-Credential $Credential
-Credential $Credential )

if ($PSBoundParameters.ContainsKey('MembersToInclude'))
{
Expand Down Expand Up @@ -971,7 +1021,7 @@ function Set-TargetResourceOnNanoServer
# Remove duplicate names as strings.
$Members = @( Remove-DuplicateMembers -Members $Members )

if ($Members.Length -gt 0)
if ($Members.Count -gt 0)
{
# Get current members
$groupMembers = Get-MembersOnNanoServer -Group $group
Expand Down Expand Up @@ -1013,7 +1063,7 @@ function Set-TargetResourceOnNanoServer
}
}

if ($MembersToInclude.Length -eq 0 -and $MembersToExclude.Length -eq 0)
if ($MembersToInclude.Count -eq 0 -and $MembersToExclude.Count -eq 0)
{
New-InvalidArgumentException -ArgumentName 'MembersToInclude and MembersToExclude' -Message ($LocalizedData.IncludeAndExcludeAreEmpty)
}
Expand Down Expand Up @@ -1180,8 +1230,6 @@ function Test-TargetResourceOnNanoServer

if ($PSBoundParameters.ContainsKey('Members'))
{
Write-Verbose 'Testing Members...'

if ($PSBoundParameters.ContainsKey('MembersToInclude'))
{
New-InvalidArgumentException -ArgumentName 'MembersToInclude' -Message ($LocalizedData.MembersAndIncludeExcludeConflict -f 'Members', 'MembersToInclude')
Expand All @@ -1198,9 +1246,9 @@ function Test-TargetResourceOnNanoServer
# Get current members
$groupMembers = Get-MembersOnNanoServer -Group $group

if ($expectedMembers.Length -ne $groupMembers.Length)
if ($expectedMembers.Count -ne $groupMembers.Count)
{
Write-Verbose -Message ($LocalizedData.MembersNumberMismatch -f 'Members', $expectedMembers.Length, $groupMembers.Length)
Write-Verbose -Message ($LocalizedData.MembersNumberMismatch -f 'Members', $expectedMembers.Count, $groupMembers.Count)
return $false
}

Expand Down Expand Up @@ -1378,7 +1426,7 @@ function Get-MembersOnFullSKU

$members = New-Object -TypeName 'System.Collections.ArrayList'

$membersAsPrincipals = Get-MembersAsPrincipals -Group $Group -PrincipalContexts $PrincipalContexts -Disposables $Disposables -Credential $Credential
$membersAsPrincipals = @( Get-MembersAsPrincipals -Group $Group -PrincipalContexts $PrincipalContexts -Disposables $Disposables -Credential $Credential )

foreach ($membersAsPrincipal in $membersAsPrincipals)
{
Expand Down Expand Up @@ -1518,7 +1566,7 @@ function Get-MembersAsPrincipals
# The account is domain qualified - credential required to resolve it.
elseif ($null -ne $Credential -or $null -ne $principalContext)
{
Write-Verbose -Message ($LocalizedData.ResolvingDomainAccount -f $scope, $accountName)
Write-Verbose -Message ($LocalizedData.ResolvingDomainAccount -f $accountName, $scope)
}
else
{
Expand Down Expand Up @@ -1858,7 +1906,14 @@ function Get-PrincipalContext
elseif ($null -ne $Credential)
{
# Create a PrincipalContext targeting $Scope using the network credentials that were passed in.
$principalContextName = "$($Credential.Domain)\$($Credential.UserName)"
if ($Credential.Domain)
{
$principalContextName = "$($Credential.Domain)\$($Credential.UserName)"
}
else
{
$principalContextName = $Credential.UserName
}
$principalContext = New-Object -TypeName 'System.DirectoryServices.AccountManagement.PrincipalContext' -ArgumentList @( [System.DirectoryServices.AccountManagement.ContextType]::Domain, $Scope, $principalContextName, $Credential.Password )

# Cache the PrincipalContext for this scope for subsequent calls.
Expand Down Expand Up @@ -2211,7 +2266,16 @@ function Get-Group
-Disposables $Disposables `
-Scope $env:computerName

return [System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($principalContext, $GroupName)
try
{
$group = [System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($principalContext, $GroupName)
}
catch
{
$group = $null
}

return $group
}

<#
Expand All @@ -2236,7 +2300,10 @@ function Assert-GroupNameValid

if ($GroupName.IndexOfAny($invalidCharacters) -ne -1)
{
ThrowInvalidArgumentError -ErrorId 'GroupNameHasInvalidCharacter' -ErrorMessage ($LocalizedData.InvalidGroupName -f $GroupName, [String]::Join(' ', $invalidCharacters))
New-InvalidArgumentException `
-ArgumentName 'GroupNameHasInvalidCharacter' `
-Message ($LocalizedData.InvalidGroupName `
-f $GroupName, [String]::Join(' ', $invalidCharacters))
}

$nameContainsOnlyWhitspaceOrDots = $true
Expand All @@ -2253,7 +2320,10 @@ function Assert-GroupNameValid

if ($nameContainsOnlyWhitspaceOrDots)
{
ThrowInvalidArgumentError -ErrorId 'GroupNameHasOnlyWhiteSpacesAndDots' -ErrorMessage ($LocalizedData.InvalidGroupName -f $GroupName, [String]::Join(' ', $invalidCharacters))
New-InvalidArgumentException `
-ErrorId 'GroupNameHasOnlyWhiteSpacesAndDots' `
-Message ($LocalizedData.InvalidGroupName `
-f $GroupName, [String]::Join(' ', $invalidCharacters))
}
}

Expand Down
Loading