As part of security exercise I was asked extract all the users and their permissions in ouer Power BI environment, With introduction of PowerShell Module of Power BI and REST API's for Power BI auditing has become as easy as ever using PowerShell and API's.
In order to run the below Powershell script you first need to install MicrosoftPowerBIMgmt module in your powershell environment.
In order to run the below Powershell script you first need to install MicrosoftPowerBIMgmt module in your powershell environment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to Audit / Extract Powr BI Workspace Users | |
# Created by - Vinoth N Manoharan | |
# Version 1.0 | |
# Date - 11/09/2019 | |
import-module MicrosoftPowerBIMgmt | |
Connect-PowerBIServiceAccount | |
$Workspaces = Get-PowerBIWorkspace | |
$access = @() | |
ForEach($Workspace in $Workspaces) | |
{ $wkpacc = @() | |
$Wkpname = $Workspace.Name | |
$wkpid = $Workspace.Id | |
$APIUrl = 'groups/'+$wkpid+'/users' | |
$wkpacc = Invoke-PowerBIRestMethod -Url $APIUrl -Method Get|ConvertFrom-Json|SELECT -ExpandProperty Value|SELECT displayName,groupUserAccessRight|Add-Member -MemberType NoteProperty -Name WorkspaceName -Value $Wkpname -PassThru | |
$access += $wkpacc | |
} | |
$access|SELECT WorkspaceNAme,displayName,groupUserAccessRight|ft -AutoSize |
Copyright © 2019 Vinoth N Manoharan.The information provided in this post is provided "as is" with no implied warranties or guarantees.
No comments:
Post a Comment