pnp / PnP

SharePoint / Office 365 Developer Patterns and Practices - Archived older solutions. Please see https://aka.ms/m365pnp for updated guidance
https://aka.ms/m365pnp
Other
1.89k stars 3.31k forks source link

Get-PnPUnifiedAuditLog Exception #1917

Open ngazou opened 3 years ago

ngazou commented 3 years ago

Hello, I have an issue , when I am trying to retrieve the audit log from sharepoint by using Get-PnPUnifiedAuditLog

PowerShell code :

$SiteUrl = "https://MyTenant-admin.sharepoint.com"

$cnx = Connect-PnPOnlineWithDelegatedApp -SiteUrl $SiteUrl # connect with AAD app registration

$startDate = (Get-Date).AddDays(-1)
$endDate = (Get-Date)

$log = Get-PnPUnifiedAuditLog -StartTime $startDate -EndTime $endDate -ContentType SharePoint

Disconnect-PnPOnline

Exception

Get-PnPUnifiedAuditLog : Une exception de type 'PnP.PowerShell.Commands.Model.Teams.GraphException' a été levée.
Au caractère C:\transfert\script\KPMG.GEDLOOP.BackUpper\Main.PS1:19 : 8
+ $log = Get-PnPUnifiedAuditLog -StartTime $startDate -EndTime $endDate ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-PnPUnifiedAuditLog], GraphException
    + FullyQualifiedErrorId : PnP.PowerShell.Commands.Model.Teams.GraphException,PnP.PowerShell.Commands.ManagementApi.GetUnifiedAuditLog

image

AAD App Registration permissions

image

Used version of the PnP-PowerShell Cmdlets PnP PowerShell for SharePoint Online

I need your help please.