Check disk space and abort deployment if insufficient
A simple script to check disk space, and fail the deployment if it's below a certain threshold. Add to PreDeploy.ps1
#Disk Space predeployment check #Create two variables in Deployment Manager: # InstallationDriveToCheck = drive to check (with colon) eg. C: # AbortIfDiskSpaceLessThanMB = amount of space which is needed to succeed, in MB eg. 1024 for 1GB write-host "***Checking space on drive $InstallationDriveToCheck***" write-host "Deployment will fail if less than $AbortIfDiskSpaceLessThanMB MB available" $disk = gwmi win32_volume -Filter "driveletter='$InstallationDriveToCheck'" [int64]$freespace = ($disk.Freespace) / 1024 / 1024 #convert to MB if ($freespace -lt $AbortIfDiskSpaceLessThanMB) { write-host "Drive $InstallationDriveToCheck has insufficient disk space! ($freespace MB)" exit -1 } else { write-host "Drive $InstallationDriveToCheck has $freespace MB free, continuing..." exit 0 }
Systems Software Engineer
Redgate Software