It might free up a small amount of space don’t expect miracles. Now, whether it does much good during the image creation process is a separate debate. I added the 15-minute (900 second) timeout because when I ran the script to test it on my server, the processes never ended, so it’s good to give up at some point. The program searches your computers hard drive for data you no longer. The script enables every cleanup item possible (line #1), starts CLEANMGR.EXE (line #2), then waits for separate CLEANMGR.EXE and DISMHOST.EXE processes to complete before exiting. Microsoft created the maintenance tool disk cleanup for such Windows operating system. Run below DISM commands from elevated prompt. Run Disk Cleanup from Select C: Drive from Properties- > General -> Disk Cleanup - >Cleanup system files. (This is a three-line script, so if you copy it, make sure the first line doesn’t have a break in it.) To run that script from MDT, copy the script into your deployment share’s “Scripts” folder and set up a “Run PowerShell script” step: Cleanup below Temp folders location -> Open Start -> Run -> Type below location one-by-one and press enter. ![]() Get-Process -Name cleanmgr,dismhost -ErrorAction Silentl圜ontinue | Wait-Process -Timeout 900 Start-Process -FilePath CleanMgr.exe -ArgumentList ‘/sagerun:1’ -WindowStyle Hidden -Wait Get-ChildItem -Path ‘HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches’ | New-ItemProperty -Name StateFlags001 -Value 2 -PropertyType DWORD ![]() In Disk cleanup, select Clean up system files. To get a description of the file type, select it. ![]() Under Files to delete, select the file types to get rid of. Search for Disk cleanup from the taskbar and select it from the list of results. Running the disk cleanup tool in safe mode can help you fix the problem Windows disk cleanup is an ideal utility tool that’ll help you free up space. Combine that documentation with some sample PowerShell scripts on StackOverflow and you can see where my script was derived, I just simplified it a little: Run Disk Cleanup on a Windows 10 Computer. The bulk of the work for this was amazingly already documented by Microsoft. Since I wanted to put this into an MDT task sequence, I also wanted to wait until the process was done. It turns out that the process is fairly simple: Set registry values to say what you want to clean up and then launch CLEANMGR.EXE with the right command line options. I’ve seen a variety of blogs over the years that talk about how to do this, but I never took the time to actually try it myself.
0 Comments
Leave a Reply. |