Files
general-scripts-and-system-…/Windows-Scripts/windows-repair.ps1
T
2026-06-12 19:25:44 -06:00

62 lines
2.6 KiB
PowerShell

# Usage:
# Open PowerShell as Administrator
# win+x
# alt+a
# alt+y
# Run:
# In powershell Terminal:
# iwr -UseBasicParsing -Uri "https://git.thecoven.info/PrincessPi/general-scripts-and-system-ssssssetup/raw/branch/main/Windows-Scripts/windows-repair.ps1?nocache=$(Get-Random)" -OutFile "$env:TEMP\windows-repair-temp.ps1"; &"$env:TEMP\windows-repair-temp.ps1"
# check if hasadmin rights, if notm run script in new terminal, clopsing old
## if not, carry on
if (-not ([Security.Principal.WindowsIdentity]::GetCurrent().Groups -contains 'S-1-5-32-544')) {
# launch tghis script int new window after promopting for admin
Start-Process -FilePath 'powershell' -Verb RunAs -ArgumentList "-ExecutionPolicy Bypass -File $PSCommandPath"
# CLOSE previous terminal
exit 0
} else {
Write-Host "`nFIXING WINDOWS FULL STYLE`n"
Write-Host "ABORTING ANY SCHEDULED SHUTDOWN"
shutdown /a > $null # cmd abort scheduled shutdowns
Write-Host "GENERATING AND DISPLAYING COMPREHENSIVE STABILITY REPORT"
Start-Process "perfmon" -ArgumentList "/report" -Wait
Write-Host "GENERATING AND DISPLAYING STABILITY HISTORY"
Start-Process "perfmon" -ArgumentList "/rel" -Wait
Write-Host "CLEARING DNS"
ipconfig /flushsdns > $null
Write-Host "CLEARING ARP CACHE"
Remove-NetNeighbor -Confirm:$false > $null
Write-Host "RENEWING DHCP"
ipconfig /releasen > $null
ipconfig /renew > $null
Write-Host "LAUNCHING WINDOWS MALICIOUS SOFTWARE REMOVAL TOOL (MRT) FOLLOW DIRECTIONS FOR FULL SCAN"
Start-Process "MRT.exe" -NoNewWindow -Wait # builtin malware removal tools -ArgumentList
Write-Host "RUNNING DISM ONLINE IMAGE CLEANUP"
DISM /Online /Cleanup-Image /RestoreHealth
# Start-Process "DISM.exe" -ArgumentList "/Online /Cleanup-Image /RestoreHealth" -Wait -NoNewWindow # powershell checks image and replaces bad filesm waits to fimis
Write-Host "LAUNCHING SYSTEM FILE CHECKER (SFC)"
SFC /scannow
# Start-Process "SFC.exe" -ArgumentList "/scannow" -Wait -NoNewWindow # cmd system file checker, retreives and replaces bad system files and waits fir it to finish
Write-Host "SCHEDULING OFFLINE CHECK DISK AND REPAIR OF C: (CHKDSK)"
echo y | chkdsk /f /r C: # cmd checks C drive after reboot to waste time and fix errors (noninteractive)
Write-Host "SCHEDULING WINDOWS DEFENDER OFFLINE SCAN MAY REBOOT UNEXPECTEDL"
Start-MpWDOScan # powershell starts Windows Defender Offline Scan after reboot
Write-Host "SCHEDULINMG OFFLINE MEMTEST"
mdsched.exe
Write-Host "`nREBOOTING IN 5 MINUTES MAX PROVBABLY SOONER`n"
shutdown /r /t 300
}