-
Notifications
You must be signed in to change notification settings - Fork 0
/
TronNG.ps1
103 lines (77 loc) · 3.38 KB
/
TronNG.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#Requires -RunAsAdministrator
#Requires -Version 5.1
<#PSScriptInfo
.VERSION 3.2.0
.GUID 35eb535b-7e54-4412-a58b-8a0c588c0b30
.AUTHOR Gavin Eke @GavinEke
.COMPANYNAME
.COPYRIGHT
.TAGS TronNG
.LICENSEURI
.PROJECTURI https://github.com/GavinEke/TronNG
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
.DESCRIPTION
Performs a collection of tasks that should speed-up a computers performance.
#>
$VerbosePreference = 'Continue'
$LogFile = "$env:LOCALAPPDATA\TronNG\TronNG.log"
If (-not (Test-Path -Path $LogFile)) {
New-Item -Path $($LogFile | Split-Path -Parent) -ItemType Directory -ErrorAction SilentlyContinue
New-Item -Path $($LogFile | Split-Path -Parent) -Name $($LogFile | Split-Path -Leaf) -ItemType File -ErrorAction SilentlyContinue
Write-Output 'TronNG Log' | Out-File -FilePath $LogFile
}
Write-Output "Start of TronNG - $(Get-Date)" | Tee-Object -FilePath $LogFile -Append
If ([Environment]::OSVersion.Version.Major -eq 10) {
#Prerequisite Check
# Step 0 - Create Checkpoint
If (-not ($args.Contains('-SkipStep0'))) {
Write-Output -InputObject 'Step 0 - Create Checkpoint' | Tee-Object -FilePath $LogFile -Append
Checkpoint-Computer -Description 'TronNG' -ErrorAction SilentlyContinue
}
# Step 1 - Update
If (-not ($args.Contains('-SkipStep1'))) {
Write-Output -InputObject 'Step 1 - Update' | Tee-Object -FilePath $LogFile -Append
UsoClient.exe ScanInstallWait
}
# Step 2 - Virus Scan
If (-not ($args.Contains('-SkipStep2'))) {
Write-Output -InputObject 'Step 2 - Virus Scan' | Tee-Object -FilePath $LogFile -Append
Update-MpSignature -ErrorAction SilentlyContinue
Start-MpScan -ErrorAction SilentlyContinue
}
# Step 3 - Clean-up
If (-not ($args.Contains('-SkipStep3'))) {
Write-Output -InputObject 'Step 3 - Clean-up' | Tee-Object -FilePath $LogFile -Append
Remove-Item "$env:temp\*" -Recurse -ErrorAction SilentlyContinue | Tee-Object -FilePath $LogFile -Append
Remove-Item "$env:tmp\*" -Recurse -ErrorAction SilentlyContinue | Tee-Object -FilePath $LogFile -Append
Clear-RecycleBin -Confirm:$False
}
# Step 4 - Repair
If (-not ($args.Contains('-SkipStep4'))) {
Write-Output -InputObject 'Step 4 - Repair' | Tee-Object -FilePath $LogFile -Append
Repair-Volume -DriveLetter C –Scan
}
# Step 5 - Defrag
If (-not ($args.Contains('-SkipStep5'))) {
Write-Output -InputObject 'Step 5 - Defrag' | Tee-Object -FilePath $LogFile -Append
$IsSSD = Get-Disk | Where-Object Model -match 'ssd'
If (-not ($IsSSD)) { #SSD Check
Optimize-Volume -DriveLetter C -Defrag
}
}
# Step 6 - Drive Health Check
If (-not ($args.Contains('-SkipStep6'))) {
Write-Output -InputObject 'Step 6 - Drive Health Check' | Tee-Object -FilePath $LogFile -Append
If ((Get-Disk).HealthStatus -ne 'Healthy') { #Failing Drive Check
Write-Output 'A hard drive in this computer might be failing, it is suggested you investigate all connected hard drives.' | Tee-Object -FilePath $LogFile -Append
}
}
} Else {
Write-Error 'Prerequisite Check Failed - This script can only be run on Windows 10 in an elevated shell' | Tee-Object -FilePath $LogFile -Append
}
Write-Output "End of TronNG - $(Get-Date)" | Tee-Object -FilePath $LogFile -Append
Write-Output '---------------------------' | Tee-Object -FilePath $LogFile -Append