PowerShell Disk Space Monitoring in 2025: Local and Cloud

Monitor Disk Space with PowerShell in 2025 Tracking disk space is a timeless IT task, but in 2025, PowerShell 7.4 brings cross-platform power and cloud integration to the table. Whether you’re managing local servers or Azure VMs, this guide delivers a modern script to keep your drives in check. Local Disk Monitoring (Windows/Linux) Step 1: […]

Powershell Disk Space Monitoring In 2025 Local And Cloud

Monitor Disk Space with PowerShell in 2025

Tracking disk space is a timeless IT task, but in 2025, PowerShell 7.4 brings cross-platform power and cloud integration to the table. Whether you’re managing local servers or Azure VMs, this guide delivers a modern script to keep your drives in check.

Local Disk Monitoring (Windows/Linux)

Step 1: Run the Script
Fire up PowerShell 7.4 (download from GitHub if you’re still on 5.1). Paste this:

# Get disk space in GB
$drives = Get-Volume | Where-Object {$_.OperationalStatus -eq 'OK'} | 
          Select-Object @{Name='Drive';Expression={$_.DriveLetter + ':'}}, 
                       @{Name='FreeGB';Expression={[math]::Round($_.SizeRemaining/1GB,2)}}, 
                       @{Name='TotalGB';Expression={[math]::Round($_.Size/1GB,2)}}
$drives | Format-Table -AutoSize

Step 2: Export (Optional)
Save to CSV: $drives | Export-Csv "DiskSpace_$(Get-Date -Format 'yyyyMMdd').csv" -NoTypeInformation. Open in Excel for reports.

Cloud Monitoring (Azure VMs)

Step 1: Connect
Install the Az module (Install-Module -Name Az), then log in: Connect-AzAccount.

Step 2: Query VMs
Run this to list Azure VMs and their total disk sizes:

$vms = Get-AzVM | ForEach-Object {
    $disk = Get-AzDisk -ResourceGroupName $_.ResourceGroupName -DiskName $_.StorageProfile.OsDisk.Name
    [PSCustomObject]@{VMName=$_.Name; TotalGB=$disk.DiskSizeGB; FreeGB='Requires VM Agent'}
}
$vms | Format-Table -AutoSize

Step 3: Advanced Option
For true free space, install the Azure VM agent and use Invoke-AzVMRunCommand to run Get-Volume remotely—contact us for a full script!

2025 Edge: Why PowerShell 7?

PowerShell 7.4’s speed and JSON support (try $drives | ConvertTo-Json) outshine old 5.1 Get-PSDrive tricks. It’s cross-platform—run it on Linux with no changes.

Want more automation? See our Windows 11 Deployment Guide for setup tips.

More Guides You Might Have Missed

🛠️

Gear We Recommend

Protecting your data? Here’s the storage and backup gear we trust.

Browse our Storage & Backup picks on Amazon

As an Amazon Associate, TechyGeeksHome earns from qualifying purchases.


Discover more from TechyGeeksHome

Subscribe to get the latest posts sent to your email.

Andrew Armstrong

Andrew Armstrong is a UK-based IT professional with 26+ years of hands-on experience in Windows, Windows Server, SCCM/ConfigMgr, Active Directory, PowerShell, and enterprise infrastructure.

He founded TechyGeeksHome in 2010 and has published over 1,500 practical guides covering real-world IT problems and solutions. When not solving IT problems,

Andrew develops free Windows utilities including Ultimate Settings Panel, which has been downloaded over 850,000 times.