What scrips did you run I ask as well.
But something I have encountered on two of my computers this week is I put 22H2 updates on my windows 10 Pc's and all fine. Till the next day on turning Pc on the install of Windows 10 was hosed?
Slapped on Windows 11 and all good now.
Wonder if you got the update as well
It has been almost a month since I ran the script (or 2), but I found some from my browser history. I suspect this one:
##_Gets total disk space available before cleaning starts
$diskBefore = (Get-WmiObject Win32_LogicalDisk).FreeSpace | Measure-Object -Sum
$before = [math]::Round($diskBefore.Sum/1MB,2)
Write-Host "Starting Disk Usage: $before MB"
##_Disk Cleanup
##_Create reg keys
if (!(Test-Path("HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files"))) { New-Item "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files" -Force | New-ItemProperty -Name 'LastAccess' -Value '2' -Force | Out-Null; } else { Get-Item "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files" | New-ItemProperty -Name 'LastAccess' -Value '2' -Force | Out-Null;}
$regKeys = @(
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\BranchCache",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\RetailDemo Offline Content",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Defender",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows ESD installation files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Reset Log Files",
"HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files")
foreach($key in $regKeys){
if (!(Test-Path("$key"))) { New-Item "$key" -Force | New-ItemProperty -Name 'StateFlags0420' -Value '2' -Force | Out-Null; } else { Get-Item "$key" | New-ItemProperty -Name 'StateFlags0420' -Value '2' -Force | Out-Null;}
}
##_Run Disk Cleanup
Start-Process -Wait "$env:SystemRoot\System32\cleanmgr.exe" -ArgumentList "/sagerun:420"
##_Purge the Temp folders
##Remove-Item -Path $env:TEMP* -Recurse -Force
##System Temp
$systemTempPath = Join-Path -Path $env:windir -ChildPath '\Temp'
Get-ChildItem -Path $systemTempPath | Where-Object { $.LastWriteTime -lt (Get-Date).AddDays(-30) } | Remove-Item -Recurse -Force -Confirm:$false
##_User Temp
$userProfiles = Get-ChildItem -Path C:\Users -Directory
##_Iterate through each user profile
foreach ($userProfile in $userProfiles) {
$userName = $userProfile.Name
$tempFolderPath = Join-Path -Path $userProfile.FullName -ChildPath 'AppData\Local\Temp'
##_Check if the "\AppData\Local\Temp" folder exists for the user
if (Test-Path -Path $tempFolderPath -PathType Container) {
##_Cleanup all files in "\AppData\Local\Temp" for the user that are older than 30 days
Get-ChildItem -Path $tempFolderPath | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-30) } | Remove-Item -Recurse -Force -Confirm:$false
} else {
Write-Host "No Temp folder found for $userName."
}
}
##_Remove junk Windows Apps
##_List Packages
##_Get-AppxPackage -AllUsers | Select Name, PackageFullName
get-appxpackage -AllUsers *BingNews* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *WindowsMaps* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *YourPhone* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *xboxapp* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *Microsoft.XboxApp* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *Microsoft.Xbox.* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *XboxGamingOverlay* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *XboxIdentityProvider* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *XboxSpeechToTextOverlay* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *SkypeApp* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *XboxOneSmartGlass* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers Microsoft.windowscommunicationsapps | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *ZuneMusic* | remove-appxpackage -AllUsers
get-appxpackage -AllUsers *ZuneVideo* | remove-appxpackage -AllUsers
##_Empty the Recycle Bin
$driveName = (Get-ChildItem -Path Env:\SystemDrive).Value
Remove-Item -Path $driveName`$recycle.bin -Recurse -Force -Confirm:$false
##_Clean up system packages (C:\Windows\WinSxS)
#dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
##_Gets the available space of all drives after cleaning
$diskAfter = (Get-WmiObject Win32_LogicalDisk).FreeSpace | Measure-Object -Sum
##_Uses the values from the total disk space used before and after this script to calculate
##_total space saved, then converts it to MBs for easier reading
$after = [math]::Round($diskAfter.Sum/1MB,2)
$saved = [math]::Round(($before - $after),2)
$savedGBs = [math]::Round(($saved * 1024 * 1024 / 1GB),2)
##_If there is less space than before the script started just report back 0
If($saved -gt 0) {
$saved = 0
}
##_Formats the output so we can split vars
Write-Output "before=$before|after=$after|spaceSaved=$($saved)MBs|spaceSavedGBs=$($savedGBs)GBs"
Write-Host "Ending Disk Usage: $after MB"
Write-Host "Ending Saved: $saved MB"
Exit 0
And the second one might have been:
This script will just run without any prompts so please make sure you test and are are happy with it before running on live systems. You can always just comment out what you don't want, such as event logs.
==========================================================================
Save the this as "Windows_Cleanup.cmd" (Batch File)
powershell.exe -ExecutionPolicy Bypass -File "%~dp0\Windows_Cleanup.ps1"
pause
==========================================================================
Save this as "Windows_Cleanup.PS1" (Power shell Script)
# Written by Fabian Castagna
# Used as a complete windows cleanup tool
# 15-7-2016
function Delete-ComputerRestorePoints{
[CmdletBinding(SupportsShouldProcess=$True)]param(
[Parameter(
Position=0,
Mandatory=$true,
ValueFromPipeline=$true
)]
$restorePoints
)
begin{
$fullName="SystemRestore.DeleteRestorePoint"
#check if the type is already loaded
$isLoaded=([AppDomain]::CurrentDomain.GetAssemblies() | foreach {$_.GetTypes()} | where {$_.FullName -eq $fullName}) -ne $null
if (!$isLoaded){
$SRClient= Add-Type -memberDefinition @"
[DllImport ("Srclient.dll")]
public static extern int SRRemoveRestorePoint (int index);
"@ -Name DeleteRestorePoint -NameSpace SystemRestore -PassThru
}
}
process{
foreach ($restorePoint in $restorePoints){
if($PSCmdlet.ShouldProcess("$($restorePoint.Description)","Deleting Restorepoint")) {
[SystemRestore.DeleteRestorePoint]::SRRemoveRestorePoint($restorePoint.SequenceNumber)
}
}
}
}
Write-Host "Deleting System Restore Points"
Get-ComputerRestorePoint | Delete-ComputerRestorePoints # -WhatIf
Write-host "Checking to make sure you have Local Admin rights" -foreground yellow
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Warning "Please run this script as an Administrator!"
If (!($psISE)){"Press any key to continue…";[void][System.Console]::ReadKey($true)}
Exit 1
}
Write-Host "Capture current free disk space on Drive C" -foreground yellow
$FreespaceBefore = (Get-WmiObject win32_logicaldisk -filter "DeviceID='C:'" | select Freespace).FreeSpace/1GB
Write-host "Deleting Rouge folders" -foreground yellow
if (test-path C:\Config.Msi) {remove-item -Path C:\Config.Msi -force -recurse}
if (test-path c:\Intel) {remove-item -Path c:\Intel -force -recurse}
if (test-path c:\PerfLogs) {remove-item -Path c:\PerfLogs -force -recurse}
# if (test-path c:\swsetup) {remove-item -Path c:\swsetup -force -recurse} # HP Software and Driver Repositry
if (test-path $env:windir\memory.dmp) {remove-item $env:windir\memory.dmp -force}
Write-host "Deleting Windows Error Reporting files" -foreground yellow
if (test-path C:\ProgramData\Microsoft\Windows\WER) {Get-ChildItem -Path C:\ProgramData\Microsoft\Windows\WER -Recurse | Remove-Item -force -recurse}
Write-host "Removing System and User Temp Files" -foreground yellow
Remove-Item -Path "$env:windir\Temp\*" -Force -Recurse
Remove-Item -Path "$env:windir\minidump\*" -Force -Recurse
Remove-Item -Path "$env:windir\Prefetch\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Temp\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\WER\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\IECompatCache\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\IECompatUaCache\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\IEDownloadHistory\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\INetCache\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Windows\INetCookies\*" -Force -Recurse
Remove-Item -Path "C:\Users\*\AppData\Local\Microsoft\Terminal Server Client\Cache\*" -Force -Recurse
Write-host "Removing Windows Updates Downloads" -foreground yellow
Stop-Service wuauserv -Force -Verbose
Stop-Service TrustedInstaller -Force -Verbose
Remove-Item -Path "$env:windir\SoftwareDistribution\*" -Force -Recurse
Remove-Item $env:windir\Logs\CBS\* -force -recurse
Start-Service wuauserv -Verbose
Start-Service TrustedInstaller -Verbose
Write-host "Checkif Windows Cleanup exists" -foreground yellow
#Mainly for 2008 servers
if (!(Test-Path c:\windows\System32\cleanmgr.exe)) {
Write-host "Windows Cleanup NOT installed now installing" -foreground yellow
copy-item $env:windir\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe $env:windir\System32
copy-item $env:windir\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui $env:windir\System32\en-US
}
Write-host "Running Windows System Cleanup" -foreground yellow
#Set StateFlags setting for each item in Windows disk cleanup utility
$StateFlags = 'StateFlags0013'
$StateRun = $StateFlags.Substring($StateFlags.get_Length()-2)
$StateRun = '/sagerun:' + $StateRun
if (-not (get-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders' -name $StateFlags)) {
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\BranchCache' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\User file versions' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Defender' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Temp Files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows ESD installation files' -name $StateFlags -type DWORD -Value 2
set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files' -name $StateFlags -type DWORD -Value 2
}
Write-host "Starting CleanMgr.exe.." -foreground yellow
Start-Process -FilePath CleanMgr.exe -ArgumentList $StateRun -WindowStyle Hidden -Wait
Write-host "Clearing All Event Logs" -foreground yellow
wevtutil el | Foreach-Object {Write-Host "Clearing $_"; wevtutil cl "$_"}
Write-host "Disk Usage before and after cleanup" -foreground yellow
$FreespaceAfter = (Get-WmiObject win32_logicaldisk -filter "DeviceID='C:'" | select Freespace).FreeSpace/1GB
"Free Space Before: {0}" -f $FreespaceBefore
"Free Space After: {0}" -f $FreespaceAfter
I am searching if there might have been another script that looks familiar that might have been the it.
I tried to switch to my bios from the current one to the original with the switch on the mobo and booting up the pc, but it didn't help.