microsoft-graph-apioffice365microsoft-graph-securitydata-governance

How to get label activity reports ( O365 Data Governance) user level and file level programatically?


I used labels and policies in Data Governance. After I auto-published the label, I see the individual files in OneDrive getting tagged with a label.

I need to programmatically check if there are any labels associated with the file and categorize them. I don't see the labels data while querying through Graph as well.

https://graph.microsoft.com/v1.0/me/drive/root/children/test.txt

Do we have any powershell commands or REST API to get these data in granular level?

https://learn.microsoft.com/en-us/office365/securitycompliance/view-label-activity-for-documents?redi...

Thanks, Madhan


Solution

  • Have you tried this for retrieving LabelActivity:

    https://learn.microsoft.com/en-us/powershell/module/exchange/policy-and-compliance-retention/get-compliancetag?view=exchange-ps

    For your first question on retrieving Labels from Graph, you can try the below query to check if it provides label info. I haven't tried myself.

    GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}?expand=fields

    You can constructSharePointId using the information from SharePointIds from the query below: https://graph.microsoft.com/v1.0/drive/root/children?$select=Name,sharepointIds