Skip to content

Commit

Permalink
xGroup: prohibit NewName for not-existing group
Browse files Browse the repository at this point in the history
Don’t allow the NewName parameter to set SamAccountName when creating an entirely new gorup.
  • Loading branch information
gaelicWizard committed May 23, 2021
1 parent f65353d commit e08dece
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,15 @@ function Set-TargetResourceOnFullSKU

if (-not $groupOriginallyExists)
{
foreach ($incompatibleParameterName in @( 'NewName' ))
{
if ($PSBoundParameters.ContainsKey($incompatibleParameterName))
{
New-InvalidArgumentException -ArgumentName $incompatibleParameterName `
-Message ($script:localizedData.NewGroupNewNameConflict -f 'NewName', $incompatibleParameterName)
}
}

$localPrincipalContext = Get-PrincipalContext -PrincipalContextCache $principalContextCache `
-Disposables $disposables -Scope $env:COMPUTERNAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ConvertFrom-StringData @'
NoConfigurationRequiredGroupDoesNotExist = Group {0} does not exist on this node. No action required.
CouldNotFindPrincipal = Could not find a principal with the provided name {0}.
MembersAndIncludeExcludeConflict = The {0} and {1} parameters conflict. The {0} parameter should not be used in any combination with the {1} parameter.
NewGroupNewNameConflict = The {0} parameter cannot be used when creating a new group.
GroupAndMembersEmpty = Members is empty and group {0} has no members. No change to group members is needed.
MemberIsNotALocalUser = {0} is not a local user. User's principal source is {1}.
MemberNotValid = The group member {0} does not exist or cannot be resolved.
Expand Down

0 comments on commit e08dece

Please sign in to comment.