
Announcements
Hello!
Is there a way to use Power Automate to check a users license type and then generate a list of who has it and their onedrive storage capacity? I want the output in a way that I can use the email addresses of those listed to send emails to (if need be).
Thanks!
Rebecca
Hi @RMD211,
You can use the getOneDriveUsageAccountDetail method from the Graph API to retrieve a csv report with the OneDrive sites and their capacity based on the last 180 days of usage (you can also use different time ranges like D7 or D30).
You can use a Select action to convert that csv into an array and only retrieve the 11th column of that csv, which is the email address of the OneDrive for Business site owner.
@ManishSolanki has shared a nice approach on how to use a chunk function for this csv to array conversion.
Below is an example
1. HTTP action one requests the report (based on the last 180 days) and will get an Redirect response back with the download location of the csv report file. This action requires authentication (I used an app registration in Entra Id with the Reports.Read.All Graph API permissions).
https://graph.microsoft.com/v1.0/reports/getOneDriveUsageAccountDetail(period='D180')
2. HTTP action two only runs on has failed status (302 Redirect is a failed status). You can set this up via the Configure run after in the settings of this action. The uri is the location value from the response header of the first action, you can use this expression for that.
outputs('HTTP_-_getOneDriveUsageAccountDetail')['headers']['location']
3. The Select uses the below expression with the chunk function in the From
skip(chunk(split(replace(base64ToString(body('HTTP_-_CSV_file_from_Redirect')['$content']), decodeUriComponent('%0A'),','),','),12), 1)
4. The map field is switched to text mode (single column) with the T button on the right side. It only uses column 11 (User Principal Name), which is index 10
item()?[10]
After that you can do whatever you want with that array. For example with a join function you could use it in a To field of a Send an Email (v2) action:
join(body('Select_-_Owner_Principal_Name_of_each_OneDrive_site'), ';')