Forum Discussion

mjanecek's avatar
mjanecek
Icon for Helper I rankHelper I
2 years ago
Solved

Audit Trails For Permissions

Hi: Is there a way to go back and see when a user was added or removed from the report and dataset level access to a report in the service? 

 

For example I would like to know if I can determine when users were removed from teh Direct Access of the below report, or when the highlighted user was added?

 

 

 

  • The tenant audit logs have that detail. Talk to your tenant admin.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Thanks for the reply from lbendlin , please allow me to provide another insight:

    Hi, mjanecek 

    Can you tell me if your problem is solved? If yes, please accept
    lbendlin's reply as solution.
     

    Regarding the issue you raised, my solution is as follows:

    1.First, you may want to be aware of the following prerequisites:

    2.Second, you'll need to log in with the following code:

    Connect-PowerBIServiceAccount

    3.Then, here are two code examples to look at:

    View all activities for a user for one day

    #Input values before running the script:
    $UserEmailAddr = '[email protected]'
    $ActivityDate = '2023-03-15'
    #----------------------------------------------------------------------
    #View activity events:
    Get-PowerBIActivityEvent -StartDateTime ($ActivityDate + 'T00:00:00.000') -EndDateTime ($ActivityDate + 'T23:59:59.999') -User $UserEmailAddr
    

    View an activity for N days

    #Input values before running the script:
    $ActivityType = 'ShareReport' 
    $NbrOfDaysToCheck = 7 
    #-----------------------------------------------------------------------
    
    #Use today to start counting back the number of days to check:
    $DayUTC = (([datetime]::Today.ToUniversalTime()).Date)
    
    #Iteratively loop through each of the last N days to view events:
    For($LoopNbr=0; $LoopNbr -le $NbrOfDaysToCheck; $LoopNbr++)
    {
        $PeriodStart=$DayUTC.AddDays(-$LoopNbr)
        $ActivityDate=$PeriodStart.ToString("yyyy-MM-dd")
        Write-Verbose "Checking $ActivityDate" -Verbose
    
    #Check activity events once per loop (once per day):
        Get-PowerBIActivityEvent -StartDateTime ($ActivityDate + 'T00:00:00.000') -EndDateTime ($ActivityDate + 'T23:59:59.999') -ActivityType $ActivityType 
    }
    

    4.Finally, here is the relevant documentation, I hope it will be helpful to you:

     Access the Power BI activity log - Power BI | Microsoft Learn
    Track user activities in Power BI - Power BI | Microsoft Learn

    Of course, if you have any new ideas, you are welcome to contact us.
     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


     

2 Replies

  • The tenant audit logs have that detail. Talk to your tenant admin.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from lbendlin , please allow me to provide another insight:

    Hi, mjanecek 

    Can you tell me if your problem is solved? If yes, please accept
    lbendlin's reply as solution.
     

    Regarding the issue you raised, my solution is as follows:

    1.First, you may want to be aware of the following prerequisites:

    2.Second, you'll need to log in with the following code:

    Connect-PowerBIServiceAccount

    3.Then, here are two code examples to look at:

    View all activities for a user for one day

    #Input values before running the script:
    $UserEmailAddr = '[email protected]'
    $ActivityDate = '2023-03-15'
    #----------------------------------------------------------------------
    #View activity events:
    Get-PowerBIActivityEvent -StartDateTime ($ActivityDate + 'T00:00:00.000') -EndDateTime ($ActivityDate + 'T23:59:59.999') -User $UserEmailAddr
    

    View an activity for N days

    #Input values before running the script:
    $ActivityType = 'ShareReport' 
    $NbrOfDaysToCheck = 7 
    #-----------------------------------------------------------------------
    
    #Use today to start counting back the number of days to check:
    $DayUTC = (([datetime]::Today.ToUniversalTime()).Date)
    
    #Iteratively loop through each of the last N days to view events:
    For($LoopNbr=0; $LoopNbr -le $NbrOfDaysToCheck; $LoopNbr++)
    {
        $PeriodStart=$DayUTC.AddDays(-$LoopNbr)
        $ActivityDate=$PeriodStart.ToString("yyyy-MM-dd")
        Write-Verbose "Checking $ActivityDate" -Verbose
    
    #Check activity events once per loop (once per day):
        Get-PowerBIActivityEvent -StartDateTime ($ActivityDate + 'T00:00:00.000') -EndDateTime ($ActivityDate + 'T23:59:59.999') -ActivityType $ActivityType 
    }
    

    4.Finally, here is the relevant documentation, I hope it will be helpful to you:

     Access the Power BI activity log - Power BI | Microsoft Learn
    Track user activities in Power BI - Power BI | Microsoft Learn

    Of course, if you have any new ideas, you are welcome to contact us.
     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.