PowerShell: Disk Freespace Display

Display maximum and minimum FreeSpace in a logical disk

It is paramount for IT admins to check the available disk space in a particular system before pushing out an update or installing an application. However, to do so at scale can be intimidating, as it can quickly get out of hand.
 
With the following script, one can check the available maximum and minimum disk space of a computer easily.

Script

<#
.SYNOPSIS
This script can be used to find the maximum and minimum space in a local disk.
.DESCRIPTION
This script can be used to find the maximum and minimum space in a local disk.
.EXAMPLE
C:\PS> C:\Script\Logical_disk.ps1
Displays the maximum and minimum free space available in local disk.
#>
#identify if the drivetype is 3 for local harddrive and obtain the ‘freespace’ to find the maximum and minimum free space.

$objectdisk=gwmi win32_logicaldisk -filter drivetype=3 | Measure-object freespace -Minimum -Maximum | Select-Object -Property property,maximum,minimum
$objectdisk | Format-Table -autosize

 




    • Related Articles

    • Display Events with a particular Text

      Administrators often have to stifle through Windows logs to troubleshoot problems with their systems or applications. However, manually going through heaps of system log information to find out the root cause of an event can be quite laborious.   ...
    • Display the most recent error messages in the system logs

      Administrators often have to stifle through Windows logs to troubleshoot problems with their systems or applications. However, manually going through heaps of system log information is laborious. The following PowerShell script, when executed, will ...
    • Display the Parent Process of a given Process

      The Get-Process command in PowerShell is a well-known cmdlet to return basic process information. However, what it does not return is the parent process of a particular process. With the following script, one can find out the parent process of a ...
    • How to configure Microsoft 365 security settings using PowerShell

      As more organizations move to the cloud, it is becoming increasingly important to ensure the security of their Microsoft 365 environment. Microsoft provides a range of security settings that can be configured to enhance the security of your ...
    • Get Screen Resolution of remote computers

      Administrators sometimes have to document certain properties of the computers in their network. The most common one is the screen resolution. Doing so on a collection of remote computers only adds to the complication. However, with the help of the ...