Introduction
This is a specific need, that I just started having myself with my Windows Servicing process. I wanted to notify my users, if their devices are running low on disk space, prior to catching it with the precaching/readiness portion of my Windows as a Service process.
This is then done, with the hope of the users taking the required actions, before I spot the low disk space issues when precaching the Windows 10 upgrade, as this essentially will cause a failure.
- My WaaS process explained here: Windows as a Service
So this post will give you the details on how to do that, using my Toast Notification Script and Configuration Manager. This can be achieved with Microsoft Intune as well, using the Proactive Remediations feature. My next blog post will cover that approach. π
Configuration Manager
The first steps lies within ConfigMgr, as we initially need to locate those device being low on disk space. For this specifically, I’m using a Configuration Baseline. The entire baseline with everything included, will be available for downloadΒ in the end of the post.
Configuration Item
The used Configuration Baseline consist of a Configuration Item.Β A Configuration Item is created within the ConfigMgr console, in the Assets and Compliance workspace. For good measures, and for those new to ConfigMgr, here’s an illustration of the Configuration Item in question:
Configuration Item Settings
The Configuration Item consist of a PowerShell script. The PowerShell script is the portion that enables us to locate those devices being low on disk space.
Editing the settings of the imported Configuration Item, will give you the option to edit the PowerShell script as well:
PowerShell Script
The script in question is quite simple. It returns False if the system drive has 10% or less free disk space, and TrueΒ if not.
Now, in my environment, we don’t have any devices with less than 256GB hard drives (which essentially turns out to be 235GB due to how hard drive manufacturers calculate space compared to how Windows does, but that’s another story).
10% of 235GB is 23,5GB, which is slightly above the 20GB requirement, I have set in my readiness portion of my WaaS process. So this hopefully means, that some of my users will fix the low disk space problem, before I get to them with a new Windows 10 upgrade.
$os = Get-CimInstance Win32_OperatingSystem $systemDrive = Get-CimInstance Win32_LogicalDisk -Filter "deviceid='$($os.SystemDrive)'" if (($systemDrive.FreeSpace/$systemDrive.Size) -le '0.10') { return $false } else { return $true }
Compliance Rules
In the Compliance Rules tab of the imported Configuration Item, you will find the rule instructing the ConfigMgr client to report compliance or non-compliance.
In this case, we will want to report non-compliance if the output of the PowerShell script returns False, as this will mean that the free space of the device is currently at or below 10%.
Configuration Baseline
The Configuration Item explained in details above, is then associated with the Configuration Baseline of the same name. You will have both, if you import the download that’s available in the end of this post.
I co-manage my devices, with all work loads switched to Microsoft Intune. Therefore I need the highlighted check mark: Always apply this baseline even for co-managed clients. If you’re not co-managing your devices, this is not needed.
In the Evaluation Conditions tab, you will find the relationship with the Configuration Item:
Deployment
The Configuration Baseline is the one being deployed. In this case, I deploy it to a custom collection containing all my Windows workstations (that means no servers included).
I run the Configuration Baseline every other day, which perhaps is a bit aggressive. On the other hand, I’m in the middle of a 20H2 upgrade, and I want to catch changes to the free space of the devices rather quickly. Configure this as it suits your situation.
Non-Compliant Collection
In order for me to target the toast notification, to the devices coming out as non-compliant, I need those devices separated in a collection.
To do that, I right click the deployment of the Configuration Baseline, select Create New Collection -> Non-compliant.
As mentioned, this will create a collection for me to target the toast notification to, containing all the devices with low disk space. Below illustration is taken directly from my production environment:
Download
You can download the entire exported Configuration Baseline here, which includes the config.xml I used for the Toast Notification Script as well: CB-Detect-Low-Disk-Space.zip (7877 downloads )
Toast Notification Script
I’m going to reference you into the toast notification docs for instruction on how to setting this up. You can find everything you need to know here: Windows 10 Toast Notification Script
If the amount of details on the script seems overwhelming, don’t hesitate to reach out, and I’m happy to help with any questions.
ENJOY π
Excellent post Martin. I was working on similar concept few weeks ago and I was only using the ConfigMgr baseline and we were pushing the email alerts to users. But I never thought of pushing a toast notification to users which is really unique. I will try this in my setup. Good job.
Nice! And thank you Prajwal π
Awesome work as usual mate π
Thank you Ben, appreciate you taking the time to comment π
How did you you deploy the Toast Notification then? Sheduled daily? or just once?
I run the toast notification daily π
Hi Martin,
How do you configure it to run daily? Is it automated?
I prefferably would like to have a MECM proof solution π
Awesome Job Martin!
Hi Martin,
Notification script is very long and there are many extra functions. I would like to simplify this work of yours for the purpose of reporting only disk shortages. What would you recommend for a great project for a beginner like me? Thank you for sharing this great project.
Hi Murat, you should be able to remove a lot of the functions within the script, if you don’t need them. I would say you will be able to remove everything but the Write-Log function and the Display-ToastNotification function, but you obviously have to test this. π