How to extract all PowerBI users and workspace access using the PowerBI API or Azure Portal?

笑着哭i 提交于 2020-04-30 13:58:24

问题


New to Power BI. Trying to get a report of the Users who have access for each Dashboards. Any pointers would be helpful.

Thanks in advance!


回答1:


You can use Get-PowerBIWorkspace from Microsoft Power BI Cmdlets to get list of workspaces and then list the members of the underlying Office 365 group (unless you are using the new preview workspaces, which has no underlying Office 365 group) using Get-UnifiedGroup cmdlet. To be able to use it, you need to Connect to Exchange Online PowerShell. Then enumerate the groups, enumerate current group members, and export them to a CSV (or process the result the way you want). If you have rights, provide -Scope Organization parameter, or omit it to get a list of your workspaces.

Import-Module MicrosoftPowerBIMgmt

$password = "xxxxxxxx" | ConvertTo-SecureString -asPlainText -Force
$username = "xxxxxxxx@example.com" 
$credential = New-Object System.Management.Automation.PSCredential($username, $password)

Connect-PowerBIServiceAccount -Credential $credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange `
    -ConnectionUri https://outlook.office365.com/powershell-liveid/ `
    -Credential $credential `
    -Authentication Basic `
    -AllowRedirection

Import-PSSession $Session

$Groups = Get-PowerBIWorkspace #-Scope Organization
$Groups | ForEach-Object {
    $group = $_
    Get-UnifiedGroupLinks -Identity $group.Name -LinkType Members -ResultSize Unlimited | ForEach-Object {
        $member = $_
        New-Object -TypeName PSObject -Property @{
            Member = $member.Name
            Group = $group.Name
        }
    }
} | Export-CSV "D:\\PowerBIGroupMembers.csv" -NoTypeInformation -Encoding UTF8

Remove-PSSession $Session

Disconnect-PowerBIServiceAccount


来源:https://stackoverflow.com/questions/54702764/how-to-extract-all-powerbi-users-and-workspace-access-using-the-powerbi-api-or-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!