• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

TECHDIIP

  • Tech
  • Windows
  • Powershell
  • Scripts
  • News
  • Games

Powershell C drive Space | Multiple Computer

Checking C drive space is really important for windows computers, this article explains to you how to Check C Drive Space on multiple remote computers, here is the simple code that one can use find the C drive space.

When you want to check the C drive system drive utilization on the local computer then one can simply open my computer and can find the drive space, however when are multiple remote computers then one has to use a PowerShell script, this article provides you a simple script that prints C drive utilization of remote computers on the screen.

There are two ways one can check the C drive information, using WMI and a cmdlet Get-PSDrive, let’s discuss both ways.

On a local computer using the WMI command.

get-WmiObject win32_logicaldisk
Output

On a local computer using the Get-PSDrive command.

Get-PSDrive

C Drive Space Check on Remote Computers

We need to create a text file for storing all the servers or multiple machines lists, I named it as Allserver.txt for and saved it in my local machine c:\temp\Allserver.txt

$allservers =get-content -path "c:\temp\Allservers.txt"
foreach ($oneserver in $allservers)
{
$disk = Get-WmiObject Win32_LogicalDisk -ComputerName $oneserver -Filter "DeviceID='C:'" | Select-Object Size,FreeSpace

}
$disk.Size
$disk.FreeSpace

C Drive Space Check on Remote Computers using Get-PSDrive.

$allservers =get-content -path "c:\temp\Allservers.txt"
foreach ($oneserver in $allservers)
{
$diskinfo = invoke-command -computername $oneserver -scriptblock { Get-PSDrive C | Select-Object @{ E={$_.Used/1GB}; L='Used' }, @{ E={$_.Free/1GB}; L='Free' }<br> }
}
$diskinfo.free
$diskinfo.used

Both these two scripts work as expected, the output is the same, however when I use PSDrive then got a bit faster results than WMI.

Thank you for reading this article, if you have any questions please let us know.

Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Fixed: Discord JavaScript Error Step by Step Procedure
  • The Nvidia GeForce Experience error code 0x0003
  • Twitch Error 2000 How to Fix Twitch Network Error 2000
  • 6 Useful Softwares for Windows 11 and window 10
  • Kernel security check failure error easy way to fix
  • About Us
  • CONTACT US
  • Disclaimer
  • Privacy Policy

Copyright © 2023 techdiip.com