Monitor SharePoint Site usage using Power Automate

Site usage is always something to keep an eye on. We want to optimize our storage to the fullest don’t we?

And while site owners are probably not monitoring the storage, you as an admin, might want to check that your most critical sites have enough “room” to avoid business disruption.

Of course, you can use the native email notifications in SharePoint Admin Center when editing the storage, but this only lets you email owners. So, what if you want to action something specific (like creating a new site) when you reach your defined limit?

That’s what we’re going to look at today.

Variables

Let’s start by initializing a few variables.

First, what is the maximum percentage of data for the said site that we want to be an “alert”. We’ll call this variable MaxStoragePercent.

Then, we need a variable to store the current percentage of storage used. Let’s call this one CurrentStoragePercent.

One variable is of type float, and the other is a string. The MaxStoragePercent is set to 0.80.

To get the storage used of a site, we’ll use the Send HTTP request to SharePoint action. Use the _api/site/usage endpoint and there’s no need for headers or body.

At this point, let’s run the flow and see the results:

We can see the storage used on my site is 0.8113610…..

Let’s reduce the number of decimals, and set this value into our CurrentStoragePercent.

Note that we use the formatNumber() function with the ‘F2’ format.

Now we’ve got our current storage used with 2 decimals 👍

Site Usage Comparison

Let’s make sure we can compare those values. We used the formatNumber() function on our CurrentStoragePercent, which returns a string. So we need to convert that to a float in order to check if our current storage is greater or equal to the MaxStoragePercent.

If we run the flow we should be good 🙂

Because the site is currently using more than my defined limit, we go into the “Yes” branch.

It’s up to you to determine what’s next! 😉

Thanks for reading! 🙂

Discover more from Veronique's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading