使用PowerShell将用户添加到Power BI工作区

In this article, I am going to explain how to add users to a Power BI workspace using Power BI PowerShell. As you already know, Power BI is a business intelligence tool from Microsoft, using which we can build graphical reports and dashboards which bring some sense to our data that resides on the database. Power BI also has a web interface known as the Power BI service, which can be used to share and collaborate these reports and dashboards with multiple users within or out of the organization.

在本文中,我将解释如何使用Power BI PowerShell将用户添加到Power BI工作区。 如您所知,Power BI是Microsoft的商业智能工具,使用它我们可以构建图形报告和仪表板,从而使驻留在数据库中的数据有一定的意义。 Power BI还具有称为Power BI服务的Web界面,可用于与组织内外的多个用户共享和协作这些报告和仪表板。

In this article, we will try to add users to our Power BI workspaces. Along with this, we will also emphasize the various roles that are available within the new Power BI workspace. This is important to understand before adding the users because each user is assigned a specific role while adding them to a Power BI workspace.

在本文中,我们将尝试将用户添加到我们的Power BI工作区中。 同时,我们还将重点介绍新的Power BI工作区中可用的各种角色。 在添加用户之前了解这一点很重要,因为在将每个用户添加到Power BI工作区时,每个用户都被分配了一个特定角色。

Power BI服务中的角色 (Roles in Power BI Service)

With the addition of the new workspace in Power BI Service, customers are now able to define more granular control over their individual workspaces. We can now add multiple users to our workspaces and define role-based access for each of those users. The new workspace in Power BI Service also allows administrators to assign roles to user groups, security groups, distribution lists, etc. in addition to the individuals.

通过在Power BI Service中添加新的工作区,客户现在可以对其各自的工作区定义更精细的控制。 现在,我们可以将多个用户添加到工作区中,并为每个用户定义基于角色的访问权限。 Power BI Service中的新工作区还允许管理员除个人外,还可以将角色分配给用户组,安全组,通讯组列表等。

In order to add users to Power BI workspace, we will need to understand various roles that we can assign to a user while creating using Power Shell. There are four primary roles that are currently available to use with the new Power BI workspace and these are as follows.

为了将用户添加到Power BI工作区,我们需要了解在使用Power Shell创建时可以分配给用户的各种角色。 当前,新的Power BI工作空间可以使用四个主要角色,这些角色如下。

  1. Admin – This role is granted to special users who have the permissions to deal with the administrative tasks within the workspace like adding or removing other people or admins, or allowing any contributor to update an app in the workspace, etc. 管理员 -此角色授予有权处理工作区中的管理任务(例如添加或删除其他人或管理员,或允许任何贡献者更新工作区中的应用程序等)的特殊用户。
  2. Member – The member role is usually granted to those who have almost similar privileges as an admin, except the fact that they cannot operate on the admin users. Users with the member role can add other members in the workspace with a member or lower permission like contributor or a viewer. Apart from this, they can also publish new apps within the workspace and also update the apps 成员 –成员角色通常授予与管理员具有几乎相似特权的用户,除了他们不能对管理员用户进行操作外。 具有成员角色的用户可以在工作区中添加具有成员或较低权限的其他成员,例如贡献者或查看者。 除此之外,他们还可以在工作区中发布新应用,还可以更新应用
  3. Contributor – The contributor role has fewer privileges as compared to the member role. As a contributor, the users can add, modify, or delete content in the workspace, publish and edit new reports, copy reports from one workspace to another etc. These users can also schedule data refreshes and modify data gateway connection strings 贡献者 –与成员角色相比,贡献者角色具有更少的特权。 作为贡献者,用户可以在工作空间中添加,修改或删除内容,发布和编辑新报告,将报告从一个工作空间复制到另一个工作空间等。这些用户还可以计划数据刷新和修改数据网关连接字符串
  4. Viewer – These users have the least permissions within a workspace. They are only allowed to view and interact with certain reports without being able to modify those 查看器 –这些用户在工作空间内拥有最少的权限。 仅允许他们查看某些报表并与之交互,而不能修改那些报表

连接到Power BI服务帐户 (Connecting to the Power BI Service Account)

Now that we have some idea about the roles in Power BI service, let’s go ahead and try to assign these roles to the users. In this tutorial, I am going to use Power Shell to connect to the Power BI service account and then run commands to add the users. In my previous article, regarding Programmatic Access to Power BI PowerShell commandlets, I have explained how to use the Power Shell commandlets to work with the Power BI module. I would strongly advise having a look at it before continuing this article, to have some fair knowledge about working with PowerShell commandlets with Power BI.

现在我们对Power BI服务中的角色有了一些了解,让我们继续尝试将这些角色分配给用户。 在本教程中,我将使用Power Shell连接到Power BI服务帐户,然后运行命令以添加用户。 在上一篇文章中,关于对Power BI PowerShell命令集的编程访问 ,我已经解释了如何使用Power Shell命令集与Power BI模块一起使用。 我强烈建议您在继续本文之前先对其进行研究,以具有一些有关在Power BI中使用PowerShell Commandlet的知识。

Now, to add users to Power BI workspace, we would need to connect to the Power BI service account first. We will open the Power Shell ISE and run the following command.

现在,要将用户添加到Power BI工作区,我们需要首先连接到Power BI服务帐户。 我们将打开Power Shell ISE并运行以下命令。

Connect-PowerBIServiceAccount

Add users to Power BI

Figure 1 – Connecting to Power BI Service Account

图1 –连接到Power BI服务帐户

Once you write this command in the Power Shell console, hit Enter. You will be prompted with a username and password that you can use to sign into the Power BI service account. Click on Sign In to proceed forward.

在Power Shell控制台中编写此命令后,请按Enter。 系统将提示您输入可用于登录Power BI服务帐户的用户名和密码。 单击登录以继续。

Add users to Power BI

Figure 2 – Signing into Power BI Service Account

图2 –登录Power BI服务帐户

Once you log in to the service account successfully, you will receive a response in the Power Shell terminal as follows.

成功登录服务帐户后,您将在Power Shell终端中收到如下响应。

Add users to Power BI

Figure 3 – Power BI Service Account connected successfully

图3 – Power BI服务帐户成功连接

将用户添加到Power BI工作区 (Add users to the Power BI workspace)

Once you are logged in to the Power BI service account using Power Shell, the next step is to run the command that will add users to the workspace. But before moving forward, let us first log in to the Power BI service using the web portal to verify the current scenario. Navigate to https://app.powerbi.com and sign in with the same credentials as used to connect the Power Shell terminal.

使用Power Shell登录到Power BI服务帐户后,下一步是运行将用户添加到工作区的命令。 但是,在继续之前,让我们首先使用Web门户登录Power BI服务以验证当前方案。 导航到https://app.powerbi.com并使用与连接Power Shell终端相同的凭据登录。

As you can see, I have an additional workspace configured with the name “Staging Workspace”. Although this is an empty workspace, we can still use it to add users to this workspace.

如您所见,我还有一个名为“ Staging Workspace ”的附加工作 。 尽管这是一个空的工作区,但我们仍然可以使用它来将用户添加到该工作区。

Staging workspace

Figure 4 – Staging workspace

图4 –临时工作区

In order to view the current users in the workspace, expand the Workspaces, and select the three dots beside the workspace of your choice, in this case, it is “Staging Workspace”. From the drop-down that appears, select Workspace access.

为了查看工作空间中的当前用户,请展开“ 工作空间” ,然后选择您选择的工作空间旁边的三个点,在本例中为“ 暂存工作空间 ”。 在出现的下拉菜单中,选择Workspace access

Workspace Access

Figure 5 – Workspace Access

图5 –工作区访问

As soon as you click on Workspace access, on the right-hand pane, a window appears which displays a list of users that are currently allocated to use this workspace and their respective roles.

单击“工作区”访问权限后,在右侧窗格中,将出现一个窗口,其中显示了当前分配给使用此工作区的用户及其各自角色的列表。

Workspace Users

Figure 6 – Workspace Users

图6 –工作区用户

As you can see, there is only one user at the moment, with the admin role. One last step before proceeding to add users to Power BI workspace is to get the WorkspaceID. This can be copied from the browser address bar as follows.

如您所见,目前只有一个用户具有admin角色。 继续将用户添加到Power BI工作区之前的最后一步是获取WorkspaceID。 可以从浏览器地址栏中复制此文件,如下所示。

Fetch Workspace ID

Figure 7 – Fetch Workspace ID

图7 –提取工作区ID

Let us now go ahead and add a second user to this workspace using Power Shell as a contributor role. The command to add the user is as follows.

现在,让我们继续使用Power Shell作为贡献者角色向该工作区添加第二个用户。 添加用户的命令如下。

Add-PowerBIWorkspaceUser -Scope Organization -Id <WORKSPACE_ID> -UserEmailAddress <EMAIL_ADDRESS> -AccessRight Contributor

Once you type the above Power Shell command and hit enter, it will add the new user with a contributor role to the workspace.

键入上面的Power Shell命令并按Enter键后,它将把具有贡献者角色的新用户添加到工作区中。

Add users to Power BI

Figure 8 – Add users to Power BI workspace

图8 –将用户添加到Power BI工作区

You can verify the same by navigating to the web portal and follow the same steps as mentioned above. As you might have already guessed, the new user has been added with the contributor role.

您可以导航到Web门户并按照上述相同的步骤进行验证。 您可能已经猜到了,新用户已经添加了贡献者角色。

New User verified in Portal

Figure 9 – New User verified in Portal

图9 –在门户中验证的新用户

修改工作空间中用户的角色 (Modifying the roles of users in the workspace)

Suppose you have already added a new user to a workspace or there is an old user in the workspace, for whom the role needs to be modified. In such a case, you can run the above command again. The only change that needs to be done is to modify the name of the role at the end of the command. Let us now try and modify the role of the new user that we just added. The command will be as follows.

假设您已经向工作空间添加了新用户,或者工作空间中有一个旧用户,需要为其修改角色。 在这种情况下,您可以再次运行以上命令。 唯一需要做的更改是在命令末尾修改角色的名称。 现在让我们尝试修改刚刚添加的新用户的角色。 命令如下。

Add-PowerBIWorkspaceUser -Scope Organization -Id <WORKSPACE_ID> -UserEmailAddress <EMAIL_ADDRESS> -AccessRight Member

Add users

Figure 10 – Modified Role of existing user

图10 –现有用户的修改角色

Let us again head over to the portal to verify the same.

让我们再次转到门户进行验证。

User Role Modified

Figure 11 – User Role Modified

图11 –修改的用户角色

As you can see, the role has been updated as Member from a contributor.

如您所见,该角色已从贡献者中更新为成员

结论 (Conclusion)

In this article, I have explained how to add users to a Power BI workspace using Power BI PowerShell commandlets. We have created the report using Power BI Desktop and then published the same into Power BI Service. Power BI Service is the cloud version of Power BI which can be used to view the reports online and also share the reports and dashboards to different users.

在本文中,我已经解释了如何使用Power BI PowerShell Commandlet将用户添加到Power BI工作区。 我们已经使用Power BI Desktop创建了报告,然后将其发布到Power BI Service中。 Power BI Service是Power BI的云版本,可用于在线查看报告以及将报告和仪表板共享给不同的用户。

Finally, we have learned how to add users to Power BI workspace using the Power BI PowerShell commandlets. This process of adding users to Power BI workspace is important from an administrative point of view as it can control the users who will have access to a specific report.

最后,我们学习了如何使用Power BI PowerShell命令集将用户添加到Power BI工作区。 从管理的角度来看,将用户添加到Power BI工作区的过程非常重要,因为它可以控制将有权访问特定报告的用户。

翻译自: https://www.sqlshack.com/add-users-to-a-power-bi-workspace-using-powershell/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值