# Usage: # Open PowerShell as Administrator # win+x # alt+a # alt+y # Run: # In admin powershell Terminal: # iwr 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; powershell -NoProfile -ep Bypass -File $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 { Clear-Host # clear window # ascii art Write-Host -ForegroundColor Magenta @' .. ..... ....------.. ..:--------.. ....... ..----------.. ....---.. ...---------=------::....:----:.. ..-----=+**************=-----:... .----+****************=-----... .--=****************=-----=**+:::--:.... .-=#*********##**++=---====++**+-----:. ..:==********#=.+@%-==++===++===++*=----... .:=::******%%+-::=++====+==++====+**=--... .:+..+*****--@===-:-%--====-=+====+*#=:.. .-=.-****#=.#+===--=+===----======+*+.. .:=:+****#@#+=====-**-----*+====++**:. .. .=****=--======-..%-----%+==++***+-.. ..=++***+-.----======..*-----#+==+***#%#+.. .. .:-..---=====--------=-+==+**-@*. ............::::::.... ..=:..--===+-:-------*%+==*+#%**=. .....:-------------------------:. ..............-:..--===+-..:-------+==+==.:... ...:----------------------------::. ......:----------::=:...--==+--:.:-------+==+=:.... ....--------------------------:..... ..:::----------------=-::.:--===---:.:------=--:.... ...:---------------------------... ..:------------------=--:..:--=+=--------::.:+-..... ...------------------------------.. ...:-----------------:....----==-------:...=%*.......:::--------------------------------:.. ...--------------:+......---------------:+%%#.----------------------------:.......-----:.. .:----===-------:-.. .:--------------*%%%%=--------------========------:.......-------:... ..-:.:------------....-.=---------=#%%%%##%------------=-----------------------------------.. .:--:....:--------:##*=:.-------=#%%%%%%#%+-----------=-------------------------------------: ..:-----------------::*%%#-------=###%%%%##=--------------------------------------:............ ..:-------------------:.-#%%##+==+%%%%%%#%+------------------------...:::--------------::::::.. ...:----------------------..-#%#%%%%%%%%*+#%=-------------------------=-:....:----------------:... --------------------------:.-#%%%%%%%%+#@%%%--------------------------=++=-::---------------:... ---------------------------...+%%%%%%%#%%%%#---------------------------------------------:.... ............------.....----:....-#%%%%%%%*=------------------------------::+=---------....... ..:-... ....-----.. ....-=-------------------------------------.=*+=....... ..---:....:-----:.......:--------------------------:-------------==+=-...... .:-------------..........:---------------------------..:-------------==.......... ..-------------:... ...--------:...----------------....:-----------==-........... ..:----==------:..-.... ..--------:...:---------------.....:----------=+-..... ..------==+=++==-..+--:. .:--------.....-----------=*%=.. ..----------=+=...... ....------------........:... ..:--------.....-------+#%%#@%.. ...----------=+=...... ....---------===:............... .:----=+*#=. ..--+#**+%@@@#%+. ..:-:..=----=*=:..... :............:=::+=:--:=.=-.::=... ..*@*-+%@@@:.....-@@#%@*#@@@#%:.. ..-:..---:-#**+-......... .. ...::::....::-.:.::-.. ..*%:..*@@@*.. ..-%#%@@+%@@@@=.. ...::.=#=..-%*++=:... ... ...... .......... ..**...*#=*%:. .-*#@%+#%@@@@+... ..*%@%+...+%+=*+=-... ..*#:.-#+..+-. ..-*#**%%*%@@%=.. ..-%@@*:..+@%=:+**+=:.. ..*@#*%%=..==. .-*%@#%@##@@@#-. ...#@@%*-=%@@#:..-=++=- .:#@*-:++..==. .=#%@%*@@*%*=+*:....:.+@*::+%@@@%=......-* .-%+...=%##%-. .+@*@%*%@##*-:*+..:-==*@=..:#@+:=*:....... .:*#:..:*@@@%:. .-%@*%@#*%*#=..-%-....:+#=-.:#%-.:+-....... .+@#=.-*@@@@*.. ....-%@@@@@@=..+%*.. .-%--=+#%-.:*-. .... .-=++++++++=... .:***+++==::::... .-%#=-*#%#**#-. .............. '@ # vars $LogDir = "$env:USERPROFILE\Downloads\Repair-Log-$((Get-Date).ToString('yyyy-MM-dd-HHmm'))" # path to new log Dir $ErrorLog = "$LogDir\error.log" # error log file Write-Host "FIXING WINDOWS FULL PRINCESS PI STYLE (THIS WILL TAKE MANY HOURS AND REBOOT MORE THAN ONCE, SLOWLY)`n" -ForegroundColor Magenta Write-Host "Creating Log Dir at $LogDir 1/21" New-Item -Path "$LogDir" -ItemType Directory > $null 2>> $null # create log dir Write-Host "OPENING LOG DIR $LogDir 2/21" explorer.exe "$LogDir" Write-Host "Initialize Log File $LogFile 3/21" Write-Host "$((Get-Date).ToString('yyyy-MM-dd-HHmm'))" 2>> "$ErrorLog" Write-Host "ABORTING ANY SCHEDULED SHUTDOWN 4/21" shutdown.exe /a > $null 2>> "$ErrorLog" # cmd abort scheduled shutdowns Write-Host "Creating Log Dir at $LogDir 5/21" New-Item -Path "$LogDir" -ItemType Directory > $null 2>> "$ErrorLog" # create log dir Write-Host "GENERATING AND DISPLAYING COMPREHENSIVE STABILITY REPORT 6/21" Start-Process "perfmon.exe" -ArgumentList "/report" -Wait # running report Write-Host "GENERATING AND DISPLAYING STABILITY HISTORY REPORT 7/21" Start-Process "perfmon.exe" -ArgumentList "/rel" -Wait # historical report Write-Host "CLEARING DNS 8/21" ipconfig.exe /flushsdns > $null 2>> "$ErrorLog" # flush dns cache Write-Host "CLEARING ARP CACHE 9/21" Remove-NetNeighbor -Confirm:$false > $null 2>> "$ErrorLog" # flush ARP Table Write-Host "CLEARING ALL SAMBA CREDENTIALS 10/21" net.exe use * /delete /y > $null 2>> "$ErrorLog" # nuke all samba creds automagically Write-Host "RELEASING AND RENEWING DHCP 11/21" # release and renew dhcp ipconfig.exe /release > $null 2>> "$ErrorLog" ipconfig.exe /renew > $null 2>> "$ErrorLog" Write-Host "GETTING CONTROL OF WINDOWS UPDATE 12/21" Install-Module -Name PSWindowsUpdate -Force > $null 2>> "$ErrorLog" Import-Module PSWindowsUpdate Write-Host "UPDATING WINDOWS 13/21" Get-WindowsUpdate -AcceptAll -Install -IgnoreReboot > $null 2>> "$ErrorLog" Write-Host "UPDATING MALWARE SIGNATURES 14/21" Update-MpSignature 2>> "$ErrorLog" # update windows defender malware siggs Write-Host "RUNNING FULL WINDOWS DEFENDER SCAN 15/21" Start-MpScan -ScanType FullScan 2>> "$ErrorLog" # full windows defender scan Write-Host "RUNNING DISM ONLINE IMAGE CLEANUP 16/21" DISM.exe /Online /Cleanup-Image /RestoreHealth 2>> "$ErrorLog" # online check for bad files Write-Host "RUNNING SYSTEM FILE CHECKER (SFC) 17/21" SFC.exe /scannow 2>> "$ErrorLog" # older check for bad files Write-Host "SCHEDULING ESSENTIAL FILE CHECK ON NEXT BOOT 18/21" SFC.exe /scanonce 2>> "$ErrorLog" # check essential files on next boot Write-Host "SCHEDULING OFFLINE CHECK DISK AND REPAIR OF C: (CHKDSK) 19/21" echo y | chkdsk.exe /f /r C: > $null 2>> "$ErrorLog" # cmd checks C drive after reboot to waste time and fix errors (noninteractive via y ffuckery) Write-Host "SCHEDULINMG OFFLINE MEMTEST 20/21" mdsched.exe /s 2>> "$ErrorLog" # schedule offline memtest (noninteractive) Write-Host "SCHEDULING WINDOWS DEFENDER OFFLINE SCAN MAY REBOOT UNEXPECTEDLY 21/21" Start-MpWDOScan 2>> "$ErrorLog" # powershell starts Windows Defender Offline Scan after reboot Write-Host "`nREBOOTING IN 5 MINUTES MAX PROVBABLY SOONER`n" shutdown.exe /r /t (60*5) # shutdown in 5 minutes as failsafe Write-Host "`nDONEsiez :3~`n" }