Proactive Remediation script: notify users for low disk space and help them to see what takes up space
In this post, I will show you a quick Proactive Remediation script for Intune allowing you to display a toast notification warning to user if its device has less than 10% of disk space.
Get the script
Click on the below GitHub picture to get the Proactive Remediation script.
What it does ?
The Proactive Remediation script works as below:
- Check free disk space on device
- If there is less than 10%: display a warning to user
This toast notification warning looks like as below:
This toast allows you to display a warning to user but not only.
Indeed there are two buttons available allowing you to:
- Open a website, docx on sharepoint... with good pratices
- Open a report to show what takes up the most space on the user disk
The toast notification
Change text
You can easily customize text in the toast notification.
For that proceed as below:
Search fo the "Toast text part" line, see below:
You can customize there text as below:
Change toast picture
You can easily add your own picture in the toast.
There are two ways:
- By adding picture to Base64 format
- By uploading picture on web like blob storage and add path
Set the way to use using variable $Toast_Picture_Mode, as below:
Add the path like blob storage in variable $Toast_Logo_Path.
Add the Base64 picture in variable $Picture_Base64.
Change buttons
Hide good practices button
By default there are two buttons.
You can hide the "See good practices" button.
For that set variable $Use_Good_Pratices_Btn to $False.
See below the notification without this button:
Set good practices link
To set the link of the button, add it in variable $Good_Pratices_Link and of course be sure that variable $Use_Good_Pratices_Btn is setted to $True.
Change buttons text
To change text inside the button search variable $Toast_Button1_Text and $Toast_Button2_Text.
The user report
The user report available from by clicing on the second button looks like as below by default:
It will list below things:
- Disk space usage with free space percent
- OneDrive folders redirection status
- OneDrive usage with OneDrive size on disk percent
- 20 larger folders in C:\Users
- Larger folders on C:\
- Larger files on C:\
Choose what to display
You can easily change which part to display in the report by changing below variables to True or False:
In the below example I just want to display larger folders in C:\Users and larger files in C:
See below the result:
Add your logo
You can easily add your logo in the report.
There are two ways:
- By adding picture to Base64 format
- By uploading picture on web like blob storage and add path
Set the way to use u variable $Report_Logo_Mode, as below:
If you want to use the download way, add the path like blob storage in variable $Report_Logo_Path.
If you want to use the Base64 way, add the Base64 picture in variable $Report_Logo_Picture_Base64.
Deploy it with Proactive Remediation
1. Go to the Microsoft Endpoint Manager admin center
2. Go to Reports
3. Go to Endpoint Analytics
4. Go to Proactive Remediations
5. Click on Create script package
6. Type a name
7. Click on Next
8. Click on Detection script file
9. Browse the script Detection_script.ps1
10. Click on Next
11. Select the group
12. In the Schedule part, choose when the package should be run.
13. Click on Apply
14. Click on Next
15. Click on Create
Notification in action
See below the toast notif in action:
7 commentaires
Hy, and thank you for this article!
Is it possible to deploy this Ps1 with MECM?
Thank you!
Hello,
Didn't test but I guess you can, just run it as user and not system
Good afternoon.
Error when running script
At C:\Users\User\Desktop\Disk_Space_Detection.ps1:232 char:19
+ Sign up
+ ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quot
ation marks ("&") to pass it as part of a string.
At C:\Users\User\Desktop\Disk_Space_Detection.ps1:235 char:180
+ ... -details-target btn-link d-lg-none mt-1 color-fg-inherit"> <svg aria
Tell me what is the reason for the error with the "<" symbol?
I am curious, do you happen to have a Proactive Remediation that checks to see if the user has not configured TPM passcode?
Is it possible to change the value of 10% to either use a specific size rather than a percentage - for instance 10GB instead of 10%?
If not, is it then possible to change the value from 10% to 20%?
I tried reading through the code, and I weren't able to find it
Hi Damien./ I just wanted to say thanks for your PR scripts. They work great and when you know how to tweak to your liking its even better. You are doing a fantastic job. Keep up the great work. @tekman2300 on twitter buddy.
Hi Damien,
This proactive Remediation script is very useful. Thanks.
One question, i would like to run a powershell script from a button (instead of "See Good Practice")
I'm not an expert in Powershell, can you help on that ?
Enregistrer un commentaire