Private/Helper/Get-VolSizeFree.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Get-VolSizeFree { <# .SYNOPSIS Retrieves the free space of a specified volume in gigabytes. .DESCRIPTION This function calculates and returns the amount of free space available on the specified drive letter in gigabytes. .PARAMETER DriveLetter The drive letter of the volume to check. Default is "C". .EXAMPLE Get-VolSizeFree -DriveLetter "D" .NOTES The function uses the Get-CimInstance cmdlet to query the CIM_LogicalDisk class for free space. #> PARAM ( $DriveLetter = "C" ) RETURN [Math]::Round((Get-CimInstance -ClassName CIM_LogicalDisk | Where-Object DeviceID -like "*$DriveLetter*").FreeSpace / 1GB,2) } |