English 中文(简体)
如何利用电算表APIC还是A/63/L获取所有电算表用户和工作空间?
原标题:How to extract all PowerBI users and workspace access using the PowerBI API or Azure Portal?

New to Power BI. 设法获得每个达什板的用户的报告。 任何要点都是有益的。

提前感谢!

最佳回答

http://learn.microsoft.com 为了便于使用,您需要。 然后列举这些团体,列举现有团体成员,并将他们出口到特别志愿人员(或处理你想要的结果)。 如果你有权利,请提供<条码>-Scope Organization para amount,或略去附上你的工作空间清单。

Import-Module MicrosoftPowerBIMgmt

$password = "xxxxxxxx" | ConvertTo-SecureString -asPlainText -Force
$username = "[email protected]" 
$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
问题回答

以下是创建的文字。 首先修改了贵方书的用户名和密码。 文字收集了结果,然后打开了两条外窗(工作空间和工作空间用户)。 然后,你可以将电网结果复制/撒布成外壳。 这等于出口共享报告和仪表板。

我安装了2个局域网权力模块。 我认为,这一文字只使用微软PowerBIMgmt。

如果您有项目调查单元,请查询。

get-module -ListAvailable | where {$_.Name -like  *BI* }

并检查现有的平板。

get-command -module MicrosoftPowerBIMgmt.Admin | sort CommandType, name
get-command -module MicrosoftPowerBIMgmt.Capacities | sort CommandType, name
get-command -module MicrosoftPowerBIMgmt.Data | sort CommandType, name
get-command -module MicrosoftPowerBIMgmt.Profile | sort CommandType, name
get-command -module MicrosoftPowerBIMgmt.Reports | sort CommandType, name
get-command -module MicrosoftPowerBIMgmt.Workspaces | sort CommandType, name
get-command -module PowerBIPS | sort CommandType, name

PBI workPACES & PERmissionS

#****************
#------------------------------------------------------
# --> PBI WORKSPACES & PERMISSIONS
#
# Export PBI results to grid for copy/paste to Excel table
# * All groups (Active/Deleted)
# * All workspaces (Active)
# * All workspace permissions
#
# RestAPI call for each workspace (Group Users) 
# * https://learn.microsoft.com/en-us/rest/api/power-bi/groups/getgroupusers
#
#------------------------------------------------------ 


#****************
#------------------------------------------------------
# --> PBI Connection
#------------------------------------------------------ 
Write-Host " PBI credentials ..." -ForegroundColor Yellow -BackgroundColor DarkGreen

## PBI credentials 

$password = "myPassword" | ConvertTo-SecureString -asPlainText -Force
$username = "[email protected]" 
$credential = New-Object System.Management.Automation.PSCredential($username, $password)

## PBI connect 

Connect-PowerBIServiceAccount -Credential $credential

# Login-PowerBI


#****************
#------------------------------------------------------
# --> Workspace info 
# 
# * Get-PowerBIWorkspace > "WARNING: Defaulted to show top 100 workspaces. Use -First & -Skip or -All to retrieve more results."
# * Grid exported for workspaces
#------------------------------------------------------ 
Write-Host " Workspace info ..." -ForegroundColor Yellow -BackgroundColor DarkGreen
    
## List all groups, Select ID desired for Variables section 
## PBIWorkspace properties values are NULL if Scope is not set to Organization 
# Get-PowerBIWorkspace -Scope Organization -Filter "tolower(name) eq  BI Team POC - DEV " 

# SET
$Groups = Get-PowerBIWorkspace -Scope Organization -All | SORT @{Expression="Type"; Descending=$True}, Name

$Groups_deleted = $Groups | SELECT Id, Name, Type, State | WHERE State -EQ  Deleted 
$Groups = $Groups | SELECT Id, Name, Type, State | WHERE State -NE  Deleted 
$GroupWorkspaces = $Groups | WHERE Type -eq  Workspace  

# PRINT
$Groups_deleted | Select Id, Name, Type, State | ft –auto 
$Groups | Select Id, Name, Type, State | ft –auto 
$GroupWorkspaces | Select Id, Name, Type | ft –auto 
Get-PowerBIWorkspace -Scope Organization -Name "BI Team Sandbox" | Select Id, Name, Type | ft –auto 

# OUT GRID
$GroupsWorkspaces | Select Id, Name, Type | Out-GridView 
$Groups | Select Id, Name, Type | Out-GridView
$Groups_deleted | Select Id, Name, Type, State | Out-GridView


#------------------------------------------------------ 
## LOOP FOLDERS ##################
# * RestAPI call for each workspace (Group Users) 
# * Grid exported for workspace user access
#------------------------------------------------------ 

# Clear variable before loop to reseat array data collector 
clear-variable -name WorkspaceUsers

Write-Host " Looping ..." -ForegroundColor Yellow -BackgroundColor DarkGreen

foreach ($GroupWorkspaceId in $GroupWorkspaces.Id) {

    $WorkspaceObject = Get-PowerBIWorkspace -Scope Organization -Id $GroupWorkspaceId
    $pbiURL = "https://api.powerbi.com/v1.0/myorg/groups/$GroupWorkspaceId/users"
    $WorkspaceObject | Select Id, Name, Type | ft –auto 

    Write-Host ($WorkspaceObject.Name +" | "+ $WorkspaceObject.Type)  -ForegroundColor White -BackgroundColor Blue
    Write-Host $GroupWorkspaceId -ForegroundColor White -BackgroundColor Blue
    Write-Host $pbiURL -ForegroundColor White -BackgroundColor Blue


#****************
#------------------------------------------------------
# --> 1. API Call for WORKSPACE USERS  
#------------------------------------------------------ 
    Write-Host " API Call ..." -ForegroundColor Yellow -BackgroundColor DarkGreen
     
    ## API call
    $resultJson = Invoke-PowerBIRestMethod –Url $pbiURL –Method GET 
    $resultObject = ConvertFrom-Json -InputObject $resultJson 

    ## Collect data fields for each loop
    $WorkspaceUsers += $resultObject.Value | 
    SELECT @{n= WorkspaceId ;e={$GroupWorkspaceId}}, 
            @{n= Workspace ;e={$WorkspaceObject.Name}}, 
            displayName, 
            emailAddress, 
            @{n= UserRole ;e={$_.groupUserAccessRight}}, 
            @{n= Principle ;e={$_.principalType}} |
        SELECT Workspace, displayName, UserRole, Principle, emailAddress | 
        SORT UserRole, displayName 
    
    ## Print loop results
    $WorkspaceUsers | ft -auto | Where{$_.WorkspaceId -eq $GroupWorkspaceId} 

    clear-variable -name resultJson
    clear-variable -name resultObject

}
## END LOOP  ##################
#------------------------------------------------------ 

## Export user access for all workspaces
    $WorkspaceUsers | SORT Workspace, UserRole, displayName | Out-GridView 

the below worked for me when I ran it in PowerShell as Admin. But the output has lots of personal workspaces (since it s across the organisation) with just one member so it might be worth filtering out all personal workspaces. You may want to refer to this resource https://learn.microsoft.com/en-us/powershell/module/microsoftpowerbimgmt.workspaces/get-powerbiworkspace?view=powerbi-ps

Install-Module -Name MicrosoftPowerBIMgmt
Connect-PowerBIServiceAccount
Get-PowerBIWorkspace -Scope Organization -All | Out-file C:Workspaceuser.txt 




相关问题
Does Spring 3.0 really support JSR-286?

Does Spring 3.0 Portlet MVC really support JSR-286 aka Porlet 2.0? I ve seen anecdotal mentions of it but nothing in any documented form. If so, has anyone successfully implemented a JSR-286 plugin ...

Newbie Question about Web Content Display and Templates

Im using Liferay Portal v5.2.3 Community Edition. I have the following two questions which i hope someone would be kind enough to answer. 1.) I want to add some content to the About Us Page of my ...

Does anyone know of a decent JavaScript portal? [closed]

I m looking for a JavaScript portal but the ones I ve found so far haven t been very good. Here s what I ve found: jPolite http://trilancer.wordpress.com/jpolite/ This one, inexplicably, seems to ...

Migrating from .net to Sharepoint

What are the compatibility issues someone has to take into account when migrating from .net 3.5 to sharepoint 2007 ? I mean, libraries, COM objects, databases.. Specially about databases, it was ...

Portlet URL appending Session ID?

I m facing a problem and don t know if it is even possible, what I m trying to do: I just want to append my session ID to all my URLs which are generated in my portal? I m using JSR-268 Portlets and ...

热门标签