Forum Discussion
get-powerbiworkspace permession
Hi
I'm tryinf to get List of Power BI tenant workspaces with members. I tried to run the script below but keep getting unauthorized to run this task. My user has PowerBI admin and assigned PowerBI Service Admin as well . Do I need more permession please ?
Best regards
Sam
-----------------------------------------------------------
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
5 Replies
- lbendlinSuper User
Have you tried running this in the API sandbox?
Admin - Groups GetGroupsAsAdmin - REST API (Power BI Power BI REST APIs) | Microsoft Docs
- v-zhangtiCommunity Support
Hi, Anonymous
You can also try the following to get a list of members of the Power BI tenant workspace.
Try to use PowerShell:
Connect-PowerBIServiceAccount $Workspaces = Get-PowerBIWorkspace -Scope Organization -All $Workspaces | ForEach-Object { $Workspace = $_.name foreach ($User in $_.Users) { [PSCustomObject]@{ Workspace = $Workspace User = $User.UserPrincipalName } } } | Export-CSV "D:\\PowerBIGroupMembers.csv" -NoTypeInformation -Encoding UTF8If the script above doesn't display users, try this:
Connect-PowerBIServiceAccount $Workspaces = Get-PowerBIWorkspace -Scope Organization -All $Workspaces | ForEach-Object { $Workspace = $_.name foreach ($User in $_.Users) { [PSCustomObject]@{ Workspace = $Workspace User = $User.Identifier } } } | Export-CSV "D:\\PowerBIGroupMembers.csv" -NoTypeInformation -Encoding UTF8Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hi
Thank you for your reply
The problem is im getting "Unauthorized" when i try to run :
Get-PowerBIWorkspace -Scope Organization -All
I have PowerBI admin role and also PowerBI service admin account .. so do i miss any more permession to run this command please ?
I ran your script and got this error :
Bets regards
Sam
- v-zhangtiCommunity Support
Hi, Anonymous
You will also need the Power BI User admin privileges.
For more administrator privileges, please refer to the following link.
https://docs.microsoft.com/power-bi/admin/service-admin-administering-power-bi-in-your-organization
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.