Add-UiPathFolderUserRoles not adding user to folder in powershell

I am trying to assign Users to folder created in orchestrator using the powershell command. But somehow it does assign user to folder. Surprisingly there’s no error as well when command is executed if userId and roleId both are passed as parameter.

I am using UiPath.Powershell module version :

 $authToken = Get-UiPathAuthToken -URL $orchestratorURL -Password $orchPassword -Username $orchuserName  -TenantName $tenantName

 $folder = Get-UiPathFolder -DisplayName 'test' -AuthToken $authToken
 $user = Get-UiPathUser -UserName 'testName' -AuthToken $authToken
 $role = Get-UiPathRole -Name 'Read Only' -AuthToken $authToken
 Add-UiPathFolderUserRoles -Id $folder.Id -UserIds $user.Id -RoleIds $role.Id  -AuthToken $authToken

But if I dont pass roleId which is Optional parameter, then i get below mentioned error.

Please let me know how to “Assign access of folder to specific user” using powershell script.

@Remus_Rusanu @loginerror @AlvinStanescu Can you guys help me on this. Its been 3 days and m stuck here. I have already raised issue on github about the same.

Is it a Classic folder or a Modern Folder?

Both -UserIds and -RoleIds should be arrays. @($user.Id) and @($role.Id). I don’t have a server handy to test.

1 Like

@Remus_Rusanu It is classic folder. I dont get why is it mandatory to pass RoleId while assigning folder access to a user. I am asking because Remove-UiPathFolderUser works fine and it does its work with UserId alone.

Anyways passing both UserId and RoleID did solve the issue.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.