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

Fix SCRoleGroup #5037

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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)]
afloca marked this conversation as resolved.
Show resolved Hide resolved
[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
Loading