$cs.Sys_IsMinimumRequiredDiskspaceAvailable
Description
Section titled “Description”Checks whether the specified drive has more free space than a required minimum. Note the comparison is strictly greater than — if free space is exactly equal to minimumdiskspaceinmb, this returns $false. This also updates an internal “sufficient disk space” status flag used elsewhere for job reporting.
Syntax
Section titled “Syntax”$cs.Sys_IsMinimumRequiredDiskspaceAvailable(string drive = “C:”, double minimumdiskspaceinmb = 100)
Parameters
Section titled “Parameters”drive (String)
Section titled “drive (String)”Drive to check free disk space on. Defaults to "C:".
minimumdiskspaceinmb (Double)
Section titled “minimumdiskspaceinmb (Double)”Minimum required free disk space, in MB, that must be exceeded. Defaults to 100.
Return value
Section titled “Return value”Boolean. $true if free disk space on the drive is strictly greater than minimumdiskspaceinmb, otherwise $false.
Example
Section titled “Example”The standard PreInstall guard, using the job’s configured minimum disk space on the system drive:
if (!$cs.Sys_IsMinimumRequiredDiskspaceAvailable($global:gsSysDrive, $global:MinimumDiskspaceMB)) { throw "Minimum required disk space not available" }Check a separate data drive that a large software kit will be extracted to, with a custom threshold:
if (!$cs.Sys_IsMinimumRequiredDiskspaceAvailable("D:", 5000)){ throw "At least 5 GB free space is required on D: to extract the installation kit"}$cs.Job_WriteLog("Sufficient disk space confirmed on D:, extracting kit")