Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

PENDING Windows.old removal

  • Thread starter Thread starter Marcomile
  • Start date Start date
  • Replies Replies 5
  • Views Views 7K

Marcomile

Member
Messages
13
Reaction score
4
Points
3
HI all,
can you suggest me a way to remove Windows.old after a 20H2 Upgrade using a script to run via SCCM?
Thaknks
 
I saw that it will be deleted in 30 days but we have a lot of disk space issues , so I'd like to remove it on demand
 
Ok if you want to manually remove the windows.old folder, try these steps.

Right click C: drive and click Properties. Select Disk and from the list select the Previous Windows Installation(s) option to delete Windows.old folder.
 
I know ho to do it manually. My users have no admin grats on their PC, so I was looking for a way to push this command via SCCM
 
$path = $env:HOMEDRIVE+"\windows.old"
If(Test-Path -Path $path)
{
#create registry value
$regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations"
New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null
#start clean application
Start-Process "$env:SystemRoot\System32\cleanmgr.exe" -ArgumentList "/sagerun:1221"
Wait-Process -Name "cleanmgr"
}
 

Forum statistics

Threads
7,133
Messages
27,856
Members
18,151
Latest member
TonyGTR
Back
Top