Powershell counterpart to Add-RDMRoleToUser?

Resolved

Powershell counterpart to Add-RDMRoleToUser?

avatar

Hello,

With Get-RDMRole I'm able to list all Groups. How can I list the members of each group? Is there a counterpart to Add-RDMRoleToUser which enables me to get the Users from a Role?

Thank you!

Waldemar

All Comments (7)

avatar

Hello Waldemar,

Thanks for reaching out
The Group membership is stored in the User object.
I've included a piece of code that will write them down.
The code itself is not very elegant, but it breaks down the concept.

$groups = Get-RDMRole
$users = Get-RDMUser
foreach($g in $groups)
{
    write-host -ForegroundColor Yellow "Group: "$g.Name
    foreach($u in $users){
        $sec = [xml]$u.CustomSecurity
        if ($sec.CustomSecurity.CustomRoles.string -contains $g.ID)
        {
            Write-Host $u.Name
        }
    }
}

I hope this helps.

Best regards,

Alex Belisle

avatar

Hello Alex,

that's exactly what I was looking for. Many thanks for that!

Best regards and nice weekend
Waldemar

avatar

Hi!

I'm glad it was helpful.
Have a great one!

Do not hesitate to contact us again for any other queries or concerns.

Best regards,

Alex Belisle

avatar

Hi,
thank you Alex.

Best regards
Waldemar

avatar

Hello Alex,

i hope you are well?

I have another question, is it possible to read out the assignment of the Valut to the groups (roles)? In the property “CustomSecurity” I do not find any relation to

My goal is that i have a list of that the group has access to valuts

Best regards
Waldemar

avatar

Hello Waldemar

I think that the best way to get this information is through the CmdLet Get-RDMRoleRepositoryAccess

$vaults = Get-RDMRoleRepositoryAccess -Role (Get-RDMRole -Name ViewAll)
$vaults.Name

This should list the Vaults a Role has access to.

Let me know if this helps.

Best regards,

Alex Belisle

avatar

Hello Alex,

that's very good, thank you for the example. I needed a query like this:

$groups = Get-RDMRole
foreach ($g in $groups){
    $g.Name
    Get-RDMRoleRepositoryAccess -Role $g | Select-Object Name, Description 
}


Best regards
Waldemar