Free disk space check prior to package deploy
Would anyone else besides me find an option possibly as a PDQ Deploy step condition to check for an appropriate amount of free disk space based upon an amount entered per package or per step that would then skip deployment on any machine if the particular drive where the package or step was intending to be deployed does not meet the entered free space minimum requirement?
How does anyone currently handle avoiding attempting to deploy a package that would fill a machine's drive and therefore fail after it is full leaving a mess to cleanup?
-
You could add a PowerShell step that gathers the FreeSpace,
$FreeSpace = ( Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DeviceID -eq $env:SystemDrive } ).FreeSpace
New-ItemProperty -Path "HKLM:\HARDWARE" -Name "System Drive Free Space" -PropertyType "Qword" -Value $FreeSpace -Forcethen use a Registry Condition on your step(s) to check it.
-
I do have inventory and have a collection that distinguishes free space but I have neither been using it as a filter in every collection nor as a higher level of the drill down hierarchy. I have used many other deployment tools, Landesk, SMS (SCCM), etc. that had this type of feature and did also submit it as a feature request. I sometimes use PDQ Deploy independently and I imagine there may be some that do not have the Inventory piece so was interested in what people were doing prior to spending too much time attempting to architect my own cobbled together workaround and I believe Colby's proposal above to be an excellent method to base a temporary solution upon until such time as AA may see fit to include this feature natively.
Thank you all and Thank you specifically Colby!
-
Colby,
I wanted to get your input on my findings thusfar attempting to utilize your suggestion. I added the following line to the powershell since there seems to be a numerical limit on digits type into the number condition to check the registry and the check does find the gb of space but even though I have stop deployment with error enabled and the output log shows the lines below the deployment still continues to the next step and shows as completed successfully. Is this behavior expected? Do I need to add this check to every step in the deployment? And how would I know that the deployment failed if it continues and ends up stating success?
$Freespace = [Math]::Round($FreeSpace / 1073741824, 2)
Value : > 100. . . . . . . . . . . . . . . . . . . . . . [Fail]
Value = 96
: Condition failed because 100 was not found. -
Colby didn't do math.
$FreeSpace = ( Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DeviceID -eq $env:SystemDrive } ).FreeSpace
Change it to this:
$FreeSpace = ( Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DeviceID -eq $env:SystemDrive } ).FreeSpace / 1MB [or /1GB for gb free]
You'll notice the number is much smaller, and within the limit. -
Stephen, thanks for the quick reply. That should simplify the command well but I am still stuck on the issue of the deployment stating success when the step is failed and stop deployment with error enabled. So, it seems if I enabled this condition on every step in a deployment all of the steps would be skipped but the deployment would report as successful. I was hoping to be able to run a condition on the first step or 2 of a deployment and have the deployment fail out immediately on any machine that did not have the entered free space.
-
Ah, I guess I misinterpreted the crux of the problem here. I apologize about that. That's interesting that it is continuing to report Success.
Is your first step checking size, and putting it in the registry, and then the Second step checking that registry entry as a condition?
I believe because the first step succeeds, and the second step is just "Skipped to to registry condition", it will still report success. I believe that is the issue. I'm not sure how to combat that though.
-
Hmm, interesting. I think the best way to achieve what you want is to move the Condition logic into the PowerShell step.
$FreeSpace = ( Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DeviceID -eq $env:SystemDrive } ).FreeSpace / 1GB
if ( $FreeSpace -lt 100 ) {
Write-Output $FreeSpace
Exit 1
}Conditions can't cause a Failed status, they can only skip the step they apply to.
Please sign in to leave a comment.
Comments
11 comments