Skip to content

$cs.Sys_IsMinimumRequiredDiskspaceAvailable

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.

$cs.Sys_IsMinimumRequiredDiskspaceAvailable(string drive = “C:”, double minimumdiskspaceinmb = 100)

Drive to check free disk space on. Defaults to "C:".

Minimum required free disk space, in MB, that must be exceeded. Defaults to 100.

Boolean. $true if free disk space on the drive is strictly greater than minimumdiskspaceinmb, otherwise $false.

The standard PreInstall guard, using the job’s configured minimum disk space on the system drive:

Terminal window
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:

Terminal window
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")

$cs.Sys_GetFreeDiskSpace