- 08 Feb 2024
- 1 読む分
- 印刷する
- PDF
Check available Disk Space on Windows devices
- 更新日 08 Feb 2024
- 1 読む分
- 印刷する
- PDF
Low disk space is a silent productivity killer. To ensure critical updates and resources deploy smoothly, IT admins must proactively monitor and manage storage, preventing disks from choking on unnecessary data.
The following PowerShell script helps the IT Admins to remotely get the details about the disk space from their managed Windows devices.
Create a file on your desktop, for example, check_available_disk_space.ps1 and open it in a text editor like notepad++
Copy the contents below to the file or click here to download the file.
# Get information about drive name, available space, used space, and percentage of free space for all drives $drives = Get-WmiObject Win32_LogicalDisk | Select-Object DeviceID, VolumeName, @{Name="TotalSpace(GB)"; Expression={[math]::Round($_.Size / 1GB, 2)}}, @{Name="FreeSpace(GB)"; Expression={[math]::Round($_.FreeSpace / 1GB, 2)}} foreach ($drive in $drives) { $usedSpace = $drive.'TotalSpace(GB)' - $drive.'FreeSpace(GB)' $percentageFree = ($drive.'FreeSpace(GB)' / $drive.'TotalSpace(GB)') * 100 [PSCustomObject]@{ "Drive Name" = $drive.DeviceID "Available Space(GB)" = $drive.'FreeSpace(GB)' "Used Space(GB)" = $usedSpace "Percentage Free" = "{0:N2}%" -f $percentageFree } }
You will be able to see the details in the Output tab in the View Status report on the Scalefusion dashboard.
Follow our guide to upload & publish the PowerShell script using Scalefusion Dashboard.
Please note that to use the PowerShell scripts, the Scalefusion MDM Agent Application must be installed on the device(s). Please follow our guide to publish and install the Scalefusion MDM Agent Application.
Notes:
The scripts and their contents are sourced from various albeit authenticated Microsoft sources and forums.
Please validate the scripts on a test machine before deploying them on all your managed devices.
Scalefusion has tested these scripts, however, Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the incorrect usage of these scripts.