Skip to content

Commit

Permalink
Fix ressource
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Floca committed Sep 11, 2024
1 parent 5224df7 commit ad71ad3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ function Get-TargetResource
[System.String]
$Name,

[Parameter()]
[System.String]
$DisplayName,

[Parameter()]
[System.String]
$Description,
Expand Down Expand Up @@ -95,8 +99,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 +139,11 @@ function Set-TargetResource
[System.String]
$Name,

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

[Parameter()]
[System.String]
$Description,
Expand Down Expand Up @@ -205,6 +215,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 +258,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 name of the role. The maximum length of the name is 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 ad71ad3

Please sign in to comment.