Skip to content

Commit

Permalink
Merge pull request #5037 from swisscom/fix/SCRoleGroup
Browse files Browse the repository at this point in the history
Fix SCRoleGroup
  • Loading branch information
NikCharlebois authored Sep 11, 2024
2 parents 7939e0c + 29277bd commit 1162550
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
* IntuneAntivirusPolicyWindows10SettingCatalog
* Fixes an issue with invalid parameter definition.
FIXES [#5015](https://github.com/microsoft/Microsoft365DSC/issues/5015)
* SCRoleGroup
* Fixes an issue with creation without specifying Displayname
* Fixes an issue with Drifts because of returned Role format
FIXES [#5036](https://github.com/microsoft/Microsoft365DSC/issues/5036)
* SentinelSetting
* Initial release.
* SPOAccessControlSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ function Get-TargetResource
[System.String]
$Name,

[Parameter()]
[ValidateLength(1, 256)]
[System.String]
$DisplayName,

[Parameter()]
[System.String]
$Description,
Expand Down Expand Up @@ -95,8 +100,9 @@ function Get-TargetResource
{
$result = @{
Name = $RoleGroup.Name
DisplayName = $RoleGroup.DisplayName
Description = $RoleGroup.Description
Roles = $RoleGroup.Roles
Roles = $RoleGroup.Roles -replace "^.*\/(?=[^\/]*$)"
Ensure = 'Present'
Credential = $Credential
ApplicationId = $ApplicationId
Expand Down Expand Up @@ -134,6 +140,11 @@ function Set-TargetResource
[System.String]
$Name,

[Parameter()]
[ValidateLength(1, 256)]
[System.String]
$DisplayName,

[Parameter()]
[System.String]
$Description,
Expand Down Expand Up @@ -205,6 +216,14 @@ function Set-TargetResource
Roles = $Roles
Confirm = $false
}
# Add DisplayName Parameter equals Name if null or Empty as creation with no value will lead to a corrupted state of the created RoleGroup
if ([System.String]::IsNullOrEmpty($DisplayName))
{
$NewRoleGroupParams.Add('DisplayName', $Name)
}
else {
$NewRoleGroupParams.Add('DisplayName', $DisplayName)
}
# Remove Description Parameter if null or Empty as the creation fails with $null parameter
if ([System.String]::IsNullOrEmpty($Description))
{
Expand Down Expand Up @@ -240,6 +259,11 @@ function Test-TargetResource
[System.String]
$Name,

[Parameter()]
[ValidateLength(1, 256)]
[System.String]
$DisplayName,

[Parameter()]
[System.String]
$Description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
class MSFT_SCRoleGroup : OMI_BaseResource
{
[Key, Description("The Name parameter specifies the name of the role. The maximum length of the name is 64 characters.")] String Name;
[Write, Description("The DisplayName parameter specifies the friendly name of the role group. If the name contains spaces, enclose the name in quotation marks. This parameter has a maximum length of 256 characters.")] String DisplayName;
[Write, Description("The Description parameter specifies the description that's displayed when the role group is viewed using the Get-RoleGroup cmdlet. Enclose the description in quotation marks")] String Description;
[Write, Description("The Roles parameter specifies the management roles to assign to the role group when it's created. If a role name contains spaces, enclose the name in quotation marks. If you want to assign more that one role, separate the role names with commas.")] String Roles[];
[Write, Description("Specify if the Role Group should exist or not."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
Expand Down

0 comments on commit 1162550

Please sign in to comment.