Clean Up Storage Pre Upgrade

Just another group of tasks to add to your arsenal.  We run a Check Readiness step before our upgrades, with a minimum of 20GB Free. We have many clients that do not meet this minimum requirement and fail, and then have to remediate. While we have long term plans to automate much of this, and prevent the Task sequence from ever running on machines that don’t reach these pre-reqs, for now, a Band-Aid.

image

Step Breakdown “Storage Cleanup” Group
Run only if FreeSpace < 20GB
image

This same query is placed on several steps.  If the step that is cleaning up is successful at getting FreeSpace above 20GB, then lets continue on.  Otherwise, the last step that will run if still under 20GB is the restart, to help flush things from the previous steps.

  1. Cleanup User Temp Folders
    image
  2. Cleanup c:\Windows\Temp
    image
  3. Delete user Profiles over X Days inactive
    image

    This requires that the delprof2.exe file from Helge Klein's site. (It is in the download, as I have permission to redistribute it)
    You can change the day to any number you want and run this steps as many times as you want.  My idea was that I would start at a high number, then slowly lower it, 360, 180, 90, 60, 45, 30, 20,15,10,5, and have the wmi query on it, so as soon as it dumped enough old profiles, to get 20GB Free, it could continue on leaving newer profiles.  The script also looks up the top console user, and excludes that from the deletions, so even if the primary user hasn't logged in for awhile (on leave), it won't delete that profile (as long as it's still the top console user, and not some tech's account).  This is a powerful step, be careful with it, as you could accidentally remove a profile you didn't want to. If you have some profiles you don't ever want to delete, you can exclude them by adding an /ed:user in the script (look to Helge's documentation for more info).
  4. Cleanup WinSXS folder
    image
  5. CleanMgr – All Options
    image
    This was borrowed directly from stealthpuppy.  I had written something, but then found this and it was just easier to use this.
  6. Restart Computer
    The restart only happens if there still isn't 20GB Free Space.This will be added to the Task Sequence Module Download HERE.

Leave a Reply

Your email address will not be published. Required fields are marked *