PowerShell Disk Space Monitoring in 2025: Local and Cloud

PowerShell Disk Space Monitoring 2025 - Dark gray gradient background with white PowerShell logo, green disk icon, and Azure cloud icon

Estimated reading time: 2 minutes

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.

Share this content:

Click to rate this post!
[Total: 2 Average: 5]
PowerShell Disk Space Monitoring in 2025: Local and Cloud

Discover more from TechyGeeksHome

Subscribe to get the latest posts sent to your email.

Leave us a message...

Scroll to top