-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.ps1
More file actions
171 lines (166 loc) · 7.95 KB
/
script.ps1
File metadata and controls
171 lines (166 loc) · 7.95 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "Este script precisa ser executado como Administrador. Reiniciando com privilégios elevados..."
Start-Process powershell "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
function Show-Menu {
Clear-Host
Write-Host "------------------------------------------------------" -ForegroundColor Cyan
Write-Host " Menu Suporte N2 - IPEA" -ForegroundColor White
Write-Host "Comandos Essenciais de Manutencao para Windows 10 e 11" -ForegroundColor White
write-Host " Desenvolvido por Paulo Henrique" -ForegroundColor White
Write-Host "------------------------------------------------------" -ForegroundColor Cyan
Write-Host " Escolha uma opcao:" -ForegroundColor White
Write-Host "------------------------------------------------------" -ForegroundColor Cyan
Write-Host "1. Rodar SFC/SCANNOW" -ForegroundColor DarkRed
Write-Host "2. Rodar CHKDSK" -ForegroundColor DarkRed
Write-Host "3. Executar instalador do Driver Booster" -ForegroundColor DarkRed
Write-Host "4. Executar Revo Uninstaller" -ForegroundColor DarkRed
Write-Host "5. Executar Windows Defender" -ForegroundColor DarkRed
Write-Host "6. Limpar arquivos temporarios" -ForegroundColor DarkRed
Write-Host "7. Restaurar imagem do sistema (DISM)" -ForegroundColor DarkRed
Write-Host "8. Ver IP da maquina" -ForegroundColor DarkRed
Write-Host "9. Pingar um endereco IP" -ForegroundColor DarkRed
Write-Host "10. Sair" -ForegroundColor DarkGreen
Write-Host "------------------------------------------------------" -ForegroundColor Cyan
}
while ($true) {
Show-Menu
$escolha = Read-Host "Digite o numero da sua escolha"
switch ($escolha) {
"1" {
Write-Host "Opcao 1 selecionada: Rodando SFC/SCANNOW..." -ForegroundColor Yellow
try {
& sfc /scannow
if ($LASTEXITCODE -eq 0) {
Write-Host "SFC/SCANNOW executado com sucesso." -ForegroundColor Green
} else {
Write-Host "Erro ao executar SFC/SCANNOW. Execute o script como Administrador." -ForegroundColor Red
}
} catch {
Write-Host "Ocorreu um erro ao executar o comando." -ForegroundColor Red
}
break
}
"2" {
Write-Host "Opcao 2 selecionada: Rodando CHKDSK..." -ForegroundColor Yellow
$drive = Read-Host "Digite a letra do drive (ex: C)"
Write-Host "Verificando o drive $drive..." -ForegroundColor Yellow
try {
# Usando o comando nativo de PowerShell
Repair-Volume -DriveLetter $drive -Scan -Verbose
Write-Host "CHKDSK executado com sucesso." -ForegroundColor Green
} catch {
Write-Host "Ocorreu um erro ao executar o comando." -ForegroundColor Red
}
break
}
"3" {
Write-Host "Opcao 3 selecionada: Executando instalador do Driver Booster..." -ForegroundColor Yellow
$path = "\\storage1\bibsoft\# PH - Softwares\Dia a dia\driver_booster_setup.exe"
try {
if (Test-Path -Path $path) {
Start-Process -FilePath $path
Write-Host "Programa executado com sucesso." -ForegroundColor Green
} else {
Write-Host "Erro: Arquivo nao encontrado. Verifique o caminho." -ForegroundColor Red
}
} catch {
Write-Host "Ocorreu um erro ao executar o programa." -ForegroundColor Red
}
break
}
"4" {
Write-Host "Opcao 4 selecionada: Executando Revo Uninstaller..." -ForegroundColor Yellow
$path = "\\storage1\bibsoft\# PH - Softwares\Dia a dia\RevoUninstaller_Portable\RevoUPort.exe"
try {
if (Test-Path -Path $path) {
Start-Process -FilePath $path
Write-Host "Programa executado com sucesso." -ForegroundColor Green
} else {
Write-Host "Erro: Arquivo nao encontrado. Verifique o caminho." -ForegroundColor Red
}
} catch {
Write-Host "Ocorreu um erro ao executar o programa." -ForegroundColor Red
}
break
}
"5" {
Write-Host "Opcao 5 selecionada: Executando Windows Defender..." -ForegroundColor Yellow
$path = "\\storage1\bibsoft\#BibSoft_NEW#\1_ SOFTWARES PADRAO\PADROES\WindowsDefenderATPLocalOnboardingScript.cmd"
try {
if (Test-Path -Path $path) {
Start-Process -FilePath $path
Write-Host "Programa executado com sucesso." -ForegroundColor Green
} else {
Write-Host "Erro: Arquivo nao encontrado. Verifique o caminho." -ForegroundColor Red
}
} catch {
Write-Host "Ocorreu um erro ao executar o programa." -ForegroundColor Red
}
break
}
"6" {
Write-Host "Opcao 6 selecionada: Limpando arquivos temporarios..." -ForegroundColor Yellow
try {
$tempPaths = "$env:TEMP\*", "$env:SystemRoot\Temp\*"
foreach ($tempPath in $tempPaths) {
if (Test-Path $tempPath) {
Remove-Item -Path $tempPath -Recurse -Force -ErrorAction SilentlyContinue
}
}
Write-Host "Arquivos temporarios limpos com sucesso." -ForegroundColor Green
} catch {
Write-Host "Ocorreu um erro ao limpar os arquivos temporarios." -ForegroundColor Red
}
break
}
"7" {
Write-Host "Opcao 7 selecionada: Restaurando imagem do sistema (DISM)..." -ForegroundColor Yellow
try {
& dism /Online /Cleanup-Image /RestoreHealth
if ($LASTEXITCODE -eq 0) {
Write-Host "DISM executado com sucesso." -ForegroundColor Green
} else {
Write-Host "Erro ao executar DISM. Execute o script como Administrador." -ForegroundColor Red
}
} catch {
Write-Host "Ocorreu um erro ao executar o comando." -ForegroundColor Red
}
break
}
"8" {
Write-Host "Opcao 8 selecionada: Verificando o IP da maquina..." -ForegroundColor Yellow
try {
Get-NetIPAddress | Format-Table -Property IPAddress, InterfaceAlias, AddressFamily -AutoSize
Write-Host "Comando executado com sucesso." -ForegroundColor Green
} catch {
Write-Host "Ocorreu um erro ao executar o comando." -ForegroundColor Red
}
break
}
"9" {
Write-Host "Opcao 9 selecionada: Pingar um endereco IP..." -ForegroundColor Yellow
$endereco = Read-Host "Digite o endereco IP ou HostName para pingar"
try {
Test-Connection -ComputerName $endereco
Write-Host "Comando executado com sucesso." -ForegroundColor Green
} catch {
Write-Host "Ocorreu um erro ao executar o comando." -ForegroundColor Red
}
break
}
"10" {
Write-Host "Saindo do script. Tchau!" -ForegroundColor Red
Start-Sleep -Seconds 2
exit
}
default {
Write-Host "Opcao invalida. Por favor, digite um numero de 1 a 10." -ForegroundColor Red
break
}
}
Write-Host ""
Write-Host "Pressione qualquer tecla para continuar..." -ForegroundColor White
$null = [System.Console]::ReadKey($true)
}