Featured image of post Add Users to a Microsoft Fabric Workspace with PowerShell

Add Users to a Microsoft Fabric Workspace with PowerShell

Introduction

Yesterday we showed how to create a Microsoft Fabric workspace using PowerShell. Today, we will add users to that workspace using the FabricTools module.

Getting the Workspace

Lets see how to get the workspace we created yesterday. We will use the Get-FabricWorkspace cmdlet to retrieve the workspace details.

1
Get-FabricWorkspace -WorkspaceName BlogPostWorkspace

Workspace Details

Adding Users to the Workspace

You can add users to the workspace using the Add-FabricWorkspaceRoleAssignment function. This function allows you to specify the group and the role you want to assign them.

1
2
3
4
5
6
7
8
$AssignSQLAdmins = @{
    WorkspaceId   = (Get-FabricWorkspace -WorkspaceName BlogPostWorkspace).id
    WorkspaceRole = "Viewer"
    PrincipalId   = "f1f0057c-53d4-4a73-961a-c3f4501cbce1"
    PrincipalType = "Group"
}

Add-FabricWorkspaceRoleAssignment @AssignSQLAdmins

If you wish to add a user instead of a group, you can change the PrincipalType to User and provide the user’s Object ID.

1
2
3
4
5
6
7
$AssignJPAdmin = @{
    WorkspaceId   = (Get-FabricWorkspace -WorkspaceName BlogPostWorkspace).id
    WorkspaceRole = "Admin"
    PrincipalId   = "51c232a0-908b-4192-a375-c20407c72970"
    PrincipalType = "User"
}
Add-FabricWorkspaceRoleAssignment @AssignJPAdmin

users added

Viewing the Users Roles in the Workspace

You can view the users and their roles in the workspace using the Get-FabricWorkspaceRoleAssignment cmdlet.

1
Get-FabricWorkspaceRoleAssignment -WorkspaceId (Get-FabricWorkspace -WorkspaceName BlogPostWorkspace).id

users roles

Conclusion

In this post, we learned how to add users to a Microsoft Fabric workspace using PowerShell. We used the Add-FabricWorkspaceRoleAssignment cmdlet to assign roles to users and groups. This allows for easy management of user access within your Fabric workspace.

Built with Hugo
Theme Stack designed by Jimmy