Get-DiskUsage
Overview
Reports disk usage per folder and file, in the style of TreeSize. Returns the result as an object and writes a human readable report to Get-DiskUsage-result.txt, beside the log.
The point of the script is to answer "what is filling this disk up?" without remoting into the machine. It rolls the size of every file up into a total for each folder, so each folder reports the size of everything beneath it rather than just the files it directly contains, then reports the biggest offenders.
Because it names the exact folders consuming the space, it is well suited to spotting a runaway process, for example Dell SupportAssist repeatedly writing backups, or a log directory that has grown without limit.
Everything is self-contained: the script runs its own logic in the session it is launched in, and writes nothing to the endpoint except its report and log. Every value that shapes the report is a parameter with a default, so the same script covers whole-machine triage and a narrow drill-down into one folder.
Implementation
-
Download the component Get-DiskUsage
-
After downloading the file, click on the
Importbutton in the Datto RMM interface. -
Select the component just downloaded and add it to the Datto RMM interface.

-
After Importing the component to the Datto RMM, make sure to add the component to the
PVALGroup always.- Steps to Add the component under
PVALGroup.
i. Click onDrop Down Icon.
ii. Click onAdd to Group.
iii. Select the group asPVAL

- Steps to Add the component under
Sample Run
To execute the component over a specific machine, follow these steps:
-
Select the machine you want to run the
componenton from the Datto RMM. -
Click on the
Quick Jobbutton.

-
Search the component
Get-DiskUsageand click onSelect

-
Following are the variables which will appear during the execution of the
component.



Note: The UDF has a character limit of 255 characters. If the output exceeds this limit, the complete data will not be displayed within the UDF. For reviewing the complete output and detailed information, please refer to the Device Activity Logs.
Datto Variables
| Variable Name | Type | Default | Description |
|---|---|---|---|
| usrUDF | String | Specify the UDF number where you want to populate the data. | |
| usrPath | String | One or more paths to scan. (Default - Every local fixed volume ) | |
| Top | String | 5 | The number of largest folders to report per target, and across every target in the returned object's top-level LargestFolders. Range 1-100. (Default - 5) |
| Depth | String | 3 | How many levels below each target to record and to show in the folder tree. Sizes are always totaled to the full depth of the tree regardless of this value; it only limits how much detail is reported. Range 0-32. (Default - 3) |
| TopFile | String | 10 | The number of largest individual files to report per target. Set to 0 to omit the section. Range 0-100. (Default - 10) |
| MinimumFolderSize | String | Folders smaller than this are neither recorded nor reported. (Default - 100MB) | |
| MinimumFileSize | String | Files smaller than this are never considered for the largest file list. (Default - 100MB) | |
| CollapseThreshold | String | 80 | Percentage used to suppress pass-through folders. When a single subfolder accounts for at least this percentage of a folder's total size, the parent is omitted in favour of the subfolder. Set to 100 to disable collapsing. Range 1-100. (Default - 80) |
| ExcludePath | String | One or more case-insensitive path fragments. Any file or folder whose full path contains a fragment is skipped entirely and does not contribute to any total. | |
| FollowLink | Boolean | False | Follow junctions, symbolic links, and cloud placeholder files. Off by default, because following links double counts data that lives elsewhere and can loop indefinitely. |
Output
- stdOut
- stdError
Attachments
Changelog
2026-09-03
- Initial version of the document