-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathosfix.ps1
More file actions
75 lines (73 loc) · 3.7 KB
/
osfix.ps1
File metadata and controls
75 lines (73 loc) · 3.7 KB
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
$url1 = "https://go.microsoft.com/fwlink/?LinkId=212732"
$folder1 = "$env:appdata\msert"
$url2 = "https://go.microsoft.com/fwlink/?LinkID=799445"
$folder2 = "$env:appdata\WUA"
$url3 = "https://download.sysinternals.com/files/Autoruns.zip"
$folder3 = "$env:appdata\autoruns"
$url4 = "https://download.sysinternals.com/files/ProcessExplorer.zip"
$folder4 = "$env:appdata\procexp"
function Test-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Test-Admin) -eq $false) {
if ($elevated) {
# tried to elevate, did not work, aborting
} else {
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -executionpolicy bypass -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
}
exit
}
if (Test-Path -Path $folder1) {Write-Host "msert directory already exists, removing old version."
Remove-Item -Path $folder1 -Recurse
New-Item -Path "$env:appdata\" -Name "msert" -ItemType "directory"
Invoke-WebRequest $url1 -OutFile "$folder1\msert.exe"
Start-Process "$folder1\msert.exe"
}
else {
New-Item -Path "$env:appdata\" -Name "msert" -ItemType "directory"
Invoke-WebRequest $url1 -OutFile "$folder1\msert.exe"
Start-Process "$folder1\msert.exe"
}
if (Test-Path -Path $folder2) {Write-Host "WUA directory already exists, removing old version"
Remove-Item -Path $folder2 -Recurse
New-Item -Path "$env:appdata\" -Name "WUA" -ItemType "directory"
Invoke-WebRequest $url2 -OutFile "$folder2\WUA.exe"
Start-Process "$folder2\WUA.exe"
}
else {
New-Item -Path "$env:appdata\" -Name "WUA" -ItemType "directory"
Invoke-WebRequest $url2 -OutFile "$folder2\WUA.exe"
Start-Process "$folder2\WUA.exe"
}
if (Test-Path -Path $folder3) {Write-Host "Sysinternals directory already exists, removing old version"
Remove-Item -Path $folder3 -Recurse
New-Item -Path "$env:appdata\" -Name "autoruns" -ItemType "directory"
Invoke-WebRequest $url3 -Outfile "$folder3\autoruns.zip"
Expand-Archive -LiteralPath "$folder3\autoruns.zip" -DestinationPath "$folder3\autoruns\"
Start-Process "$folder3\autoruns\autoruns64.exe"
}
else {
New-Item -Path "$env:appdata\" -Name "autoruns" -ItemType "directory"
Invoke-WebRequest $url3 -Outfile "$env:appdata\autoruns\autoruns.zip"
Expand-Archive -LiteralPath "$env:appdata\autoruns\autoruns.zip" -DestinationPath "$env:appdata\autoruns\autoruns\"
Start-Process "$env:appdata\autoruns\autoruns\autoruns64.exe"
}
if (Test-Path -Path $folder4) {Write-Host "procexp directory already exists, removing old version"
Remove-Item -Path $folder3 -Recurse
New-Item -Path "$env:appdata\" -Name "procexp" -ItemType "directory"
Invoke-WebRequest $url4 -Outfile "$folder4\procexp.zip"
Expand-Archive -LiteralPath "$folder4\procexp.zip" -DestinationPath "$folder4\procexp\"
Start-Process "$folder4\procexp\procexp64.exe"
}
else {
New-Item -Path "$env:appdata\" -Name "procexp" -ItemType "directory"
Invoke-WebRequest $url4 -Outfile "$folder4\procexp.zip"
Expand-Archive -LiteralPath "$folder4\procexp.zip" -DestinationPath "$folder4\procexp\"
Start-Process "$folder4\procexp\procexp64.exe"
}
#Get-AppxPackage *Microsoft.Windows.SecHealthUI* | Reset-AppxPackage
#Get-AppxPackage Microsoft.SecHealthUI -AllUsers | Reset-AppxPackage
Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register -ErrorAction SilentlyContinue "$($_.InstallLocation)\AppXManifest.xml"}
Repair-WindowsImage -Online -Scanhealth -StartComponentCleanup -ResetBase