DEV Community

Cover image for Powershell - Get Hard Drive Size and Free Space
Dan Wheeler
Dan Wheeler

Posted on

Powershell - Get Hard Drive Size and Free Space

Run the following in a Powershell window

$disk = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='C:'" | Select-Object Size, FreeSpace

Write-Host ("{0}GB total" -f [math]::truncate($disk.Size / 1GB))

Write-Host ("{0}GB free" -f [math]::truncate($disk.FreeSpace / 1GB))
Enter fullscreen mode Exit fullscreen mode

To get a different drive letter, just change the C: in "DeviceID='C:'" to whatever drive you want.

Top comments (1)

Collapse
 
redhcp profile image
redhcp

Great Dan!, I posted another method here

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay