@symbeon/orbit-devops 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/skills/orbit-devops/SKILL.md +54 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +44 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +33 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +51 -0
- package/.github/dependabot.yml +64 -0
- package/ARCHITECTURE.json +98 -0
- package/AdditionalCleanup.ps1 +70 -0
- package/AnalyzeCursor.ps1 +25 -0
- package/AppDataAudit.ps1 +16 -0
- package/CHANGELOG.md +83 -0
- package/CONFIG_LOG.md +35 -0
- package/CONTRIBUTING.md +203 -0
- package/CategorizedScan.ps1 +37 -0
- package/CategorizedScan_v2.ps1 +38 -0
- package/CheckAnaconda.ps1 +9 -0
- package/CheckAppData.ps1 +8 -0
- package/CheckAppDataRoaming.ps1 +8 -0
- package/CheckBackupSizes.ps1 +17 -0
- package/CheckCacheSize.ps1 +17 -0
- package/CheckNodeModules.ps1 +17 -0
- package/CheckSpace.ps1 +2 -0
- package/CheckTargetSizes.ps1 +17 -0
- package/CheckUserRoot.ps1 +10 -0
- package/DeepStorageAnalysis.ps1 +76 -0
- package/DetailedBloatAudit.ps1 +55 -0
- package/DetailedBloatAudit_v3.ps1 +50 -0
- package/DetailedProcessAudit.ps1 +43 -0
- package/DiagnosticoSistema.ps1 +155 -0
- package/ExecuteCleanup.ps1 +73 -0
- package/ExecuteTotalCleanup.ps1 +86 -0
- package/FinalCategorizedReport.ps1 +49 -0
- package/FinalDeepDive.ps1 +34 -0
- package/ForcePush.ps1 +31 -0
- package/ForensicRAMAudit.ps1 +26 -0
- package/ForensicRAMAudit_UTF8.ps1 +32 -0
- package/ForensicRAMAudit_v2.ps1 +25 -0
- package/ForensicRAMAudit_v3.ps1 +25 -0
- package/FullRAMReport_Local.txt +0 -0
- package/FullRAMReport_UTF8.txt +1400 -0
- package/GiantHunt.ps1 +26 -0
- package/GlobalRAMAudit.ps1 +57 -0
- package/LICENSE +21 -0
- package/MeasureSuspects.ps1 +17 -0
- package/NEXT_STEPS.md +35 -0
- package/Orbit.ps1 +40 -0
- package/PostRebootCleanup.ps1 +60 -0
- package/RAMAudit.ps1 +41 -0
- package/RAMAudit_v2.ps1 +24 -0
- package/README.md +58 -0
- package/RootAudit.ps1 +14 -0
- package/RunDiagnostic.ps1 +119 -0
- package/RunDiagnosticSimple.ps1 +42 -0
- package/SECURITY.md +67 -0
- package/SETUP.md +34 -0
- package/SafeSurgery.ps1 +69 -0
- package/ScanPrograms.ps1 +13 -0
- package/ScanRepoWaste.ps1 +45 -0
- package/ScanStorage.ps1 +41 -0
- package/ScanTargets.ps1 +39 -0
- package/SimpleSurgicalAudit.ps1 +22 -0
- package/SurgicalBloatAudit.ps1 +35 -0
- package/SurgicalScan.ps1 +28 -0
- package/SystemDiagnostic.ps1 +588 -0
- package/SystemDiagnosticSimple.ps1 +141 -0
- package/SystemDiagnosticUser.ps1 +92 -0
- package/SystemDiagnosticUser_v2.ps1 +36 -0
- package/UserAudit.ps1 +23 -0
- package/bin/orbit.js +99 -0
- package/check_environment.ps1 +104 -0
- package/deep_downloads_org_log.txt +15 -0
- package/diagnostic_error.txt +83 -0
- package/diskpart_log.txt +0 -0
- package/docs/DEPRECATED_USERNAME_CHANGE.md +138 -0
- package/docs/PROJECT_STRUCTURE.md +156 -0
- package/downloads_audit.txt +32 -0
- package/downloads_audit_clear.txt +27 -0
- package/downloads_org_log.txt +85 -0
- package/mcp/README.md +61 -0
- package/mcp/server.py +109 -0
- package/package.json +39 -0
- package/scripts/mac/diagnostic.sh +46 -0
- package/scripts/stack/Push-Stack.ps1 +41 -0
- package/scripts/stack/SnapshotEnv.ps1 +22 -0
- package/scripts/utils/DeepOrganizeDownloads.ps1 +82 -0
- package/scripts/utils/OrganizeDownloads.ps1 +40 -0
- package/scripts/wsl/CompactWSL.ps1 +60 -0
- package/setup_environment.ps1 +59 -0
- package/sizes.txt +6 -0
- package/verify_environment.ps1 +46 -0
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
#Requires -RunAsAdministrator
|
|
2
|
+
# SystemDiagnostic.ps1
|
|
3
|
+
# Script de diagnóstico completo do sistema Windows
|
|
4
|
+
# Versão: 2.0
|
|
5
|
+
|
|
6
|
+
# Configuração inicial
|
|
7
|
+
$ErrorActionPreference = "Continue"
|
|
8
|
+
$ProgressPreference = "Continue"
|
|
9
|
+
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
|
10
|
+
|
|
11
|
+
# Configuração do diretório de relatórios
|
|
12
|
+
$userDesktop = [Environment]::GetFolderPath("Desktop")
|
|
13
|
+
$reportDir = Join-Path $userDesktop "SystemDiagnostics"
|
|
14
|
+
$reportPath = Join-Path $reportDir "SystemDiagnostic_Report_$timestamp.txt"
|
|
15
|
+
|
|
16
|
+
# Variáveis globais para tracking
|
|
17
|
+
$global:recommendations = @()
|
|
18
|
+
$global:errorCount = 0
|
|
19
|
+
$global:warningCount = 0
|
|
20
|
+
$global:totalSteps = 8 # Número total de etapas de diagnóstico
|
|
21
|
+
$global:currentStep = 0
|
|
22
|
+
$global:issuesSummary = @{}
|
|
23
|
+
|
|
24
|
+
# Criar diretório de relatórios se não existir
|
|
25
|
+
if (-not (Test-Path $reportDir)) {
|
|
26
|
+
try {
|
|
27
|
+
New-Item -ItemType Directory -Path $reportDir -Force | Out-Null
|
|
28
|
+
Write-Host "Diretório de relatórios criado em: $reportDir" -ForegroundColor Green
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
Write-Error "Erro ao criar diretório de relatórios: $_"
|
|
32
|
+
exit 1
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# Funções de Suporte
|
|
37
|
+
function Write-Report {
|
|
38
|
+
param(
|
|
39
|
+
[string]$Message,
|
|
40
|
+
[string]$Type = "INFO"
|
|
41
|
+
)
|
|
42
|
+
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
43
|
+
$logMessage = "[$timestamp] [$Type] $Message"
|
|
44
|
+
|
|
45
|
+
switch ($Type) {
|
|
46
|
+
"ERROR" {
|
|
47
|
+
Write-Host $logMessage -ForegroundColor Red
|
|
48
|
+
$global:errorCount++
|
|
49
|
+
}
|
|
50
|
+
"WARNING" {
|
|
51
|
+
Write-Host $logMessage -ForegroundColor Yellow
|
|
52
|
+
$global:warningCount++
|
|
53
|
+
}
|
|
54
|
+
"SUCCESS" {
|
|
55
|
+
Write-Host $logMessage -ForegroundColor Green
|
|
56
|
+
}
|
|
57
|
+
default {
|
|
58
|
+
Write-Host $logMessage
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Add-Content -Path $reportPath -Value $logMessage -Encoding UTF8
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function Show-Progress {
|
|
66
|
+
param(
|
|
67
|
+
[string]$Activity,
|
|
68
|
+
[string]$Status
|
|
69
|
+
)
|
|
70
|
+
$global:currentStep++
|
|
71
|
+
$percentComplete = [math]::Round(($global:currentStep / $global:totalSteps) * 100)
|
|
72
|
+
Write-Progress -Activity $Activity -Status $Status -PercentComplete $percentComplete
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function Write-SectionHeader {
|
|
76
|
+
param([string]$Title)
|
|
77
|
+
$header = "`n=== $Title ==="
|
|
78
|
+
Write-Report $header
|
|
79
|
+
Write-Report ("=" * $header.Length)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function Add-Recommendation {
|
|
83
|
+
param(
|
|
84
|
+
[string]$Category,
|
|
85
|
+
[string]$Issue,
|
|
86
|
+
[string]$Recommendation,
|
|
87
|
+
[string]$Severity = "Info"
|
|
88
|
+
)
|
|
89
|
+
if (-not $global:issuesSummary.ContainsKey($Category)) {
|
|
90
|
+
$global:issuesSummary[$Category] = @()
|
|
91
|
+
}
|
|
92
|
+
$global:issuesSummary[$Category] += @{
|
|
93
|
+
Issue = $Issue
|
|
94
|
+
Recommendation = $Recommendation
|
|
95
|
+
Severity = $Severity
|
|
96
|
+
Timestamp = Get-Date
|
|
97
|
+
}
|
|
98
|
+
$global:recommendations += $Recommendation
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# Início do diagnóstico
|
|
102
|
+
Write-Report "`nIniciando diagnóstico do sistema..." -Type "INFO"
|
|
103
|
+
Write-Report "Relatório será salvo em: $reportPath" -Type "INFO"
|
|
104
|
+
Write-Report "Data/Hora: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")`n" -Type "INFO"
|
|
105
|
+
|
|
106
|
+
# 1. Sistema Operacional e Hardware
|
|
107
|
+
Show-Progress -Activity "Sistema Operacional" -Status "Coletando informações básicas"
|
|
108
|
+
Write-SectionHeader "Sistema Operacional e Hardware"
|
|
109
|
+
try {
|
|
110
|
+
$os = Get-CimInstance Win32_OperatingSystem
|
|
111
|
+
$cpu = Get-CimInstance Win32_Processor
|
|
112
|
+
$ram = Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum
|
|
113
|
+
|
|
114
|
+
Write-Report "Sistema: $($os.Caption) $($os.Version)"
|
|
115
|
+
Write-Report "Arquitetura: $($os.OSArchitecture)"
|
|
116
|
+
Write-Report "Último Boot: $($os.LastBootUpTime)"
|
|
117
|
+
Write-Report "CPU: $($cpu.Name)"
|
|
118
|
+
Write-Report "Memória Total: $([math]::Round($ram.Sum/1GB, 2)) GB"
|
|
119
|
+
|
|
120
|
+
# Verificação de espaço em disco
|
|
121
|
+
Get-Volume | Where-Object {$_.DriveLetter} | ForEach-Object {
|
|
122
|
+
$free = [math]::Round($_.SizeRemaining/1GB, 2)
|
|
123
|
+
$total = [math]::Round($_.Size/1GB, 2)
|
|
124
|
+
$percentFree = [math]::Round(($_.SizeRemaining/$_.Size) * 100, 2)
|
|
125
|
+
Write-Report "Drive $($_.DriveLetter): $free GB livre de $total GB ($percentFree% livre)"
|
|
126
|
+
|
|
127
|
+
if ($percentFree -lt 10) {
|
|
128
|
+
Add-Recommendation -Category "Storage" `
|
|
129
|
+
-Issue "Pouco espaço livre no drive $($_.DriveLetter)" `
|
|
130
|
+
-Recommendation "Libere espaço no drive $($_.DriveLetter) (apenas $percentFree% livre)" `
|
|
131
|
+
-Severity "Warning"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
Write-Report "Erro ao coletar informações do sistema: $_" -Type "ERROR"
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# 2. Serviços Críticos
|
|
140
|
+
Show-Progress -Activity "Serviços" -Status "Verificando serviços críticos"
|
|
141
|
+
Write-SectionHeader "Serviços Críticos"
|
|
142
|
+
$criticalServices = @(
|
|
143
|
+
@{Name="wuauserv"; Display="Windows Update"},
|
|
144
|
+
@{Name="WinDefend"; Display="Windows Defender"},
|
|
145
|
+
@{Name="wscsvc"; Display="Security Center"},
|
|
146
|
+
@{Name="RpcSs"; Display="Remote Procedure Call"},
|
|
147
|
+
@{Name="DcomLaunch"; Display="DCOM Server Process"},
|
|
148
|
+
@{Name="EventLog"; Display="Windows Event Log"}
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
foreach ($service in $criticalServices) {
|
|
152
|
+
try {
|
|
153
|
+
$svc = Get-Service -Name $service.Name -ErrorAction Stop
|
|
154
|
+
Write-Report "$($service.Display): $($svc.Status)"
|
|
155
|
+
|
|
156
|
+
if ($svc.Status -ne "Running") {
|
|
157
|
+
Add-Recommendation -Category "Services" `
|
|
158
|
+
-Issue "Serviço $($service.Display) não está em execução" `
|
|
159
|
+
-Recommendation "Verifique e inicie o serviço $($service.Display)" `
|
|
160
|
+
-Severity "Warning"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
Write-Report "Erro ao verificar serviço $($service.Display): $_" -Type "ERROR"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# 3. Performance e Recursos
|
|
169
|
+
Show-Progress -Activity "Performance" -Status "Analisando uso de recursos"
|
|
170
|
+
Write-SectionHeader "Performance e Recursos"
|
|
171
|
+
try {
|
|
172
|
+
# CPU
|
|
173
|
+
$cpuLoad = (Get-Counter '\Processor(_Total)\% Processor Time' -ErrorAction Stop).CounterSamples.CookedValue
|
|
174
|
+
Write-Report "Uso de CPU: $([math]::Round($cpuLoad, 2))%"
|
|
175
|
+
|
|
176
|
+
if ($cpuLoad -gt 80) {
|
|
177
|
+
Add-Recommendation -Category "Performance" `
|
|
178
|
+
-Issue "Alto uso de CPU" `
|
|
179
|
+
-Recommendation "Investigue processos consumindo muito CPU" `
|
|
180
|
+
-Severity "Warning"
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
# Memória
|
|
184
|
+
$memory = Get-Counter '\Memory\Available MBytes' -ErrorAction Stop
|
|
185
|
+
$availableMemoryGB = [math]::Round($memory.CounterSamples.CookedValue/1024, 2)
|
|
186
|
+
$totalMemoryGB = [math]::Round(((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory)/1GB, 2)
|
|
187
|
+
$usedMemoryPercent = [math]::Round((($totalMemoryGB - $availableMemoryGB)/$totalMemoryGB) * 100, 2)
|
|
188
|
+
|
|
189
|
+
Write-Report "Memória Disponível: $availableMemoryGB GB de $totalMemoryGB GB ($usedMemoryPercent% em uso)"
|
|
190
|
+
|
|
191
|
+
if ($usedMemoryPercent -gt 80) {
|
|
192
|
+
Add-Recommendation -Category "Performance" `
|
|
193
|
+
-Issue "Alto uso de memória" `
|
|
194
|
+
-Recommendation "Investigue processos consumindo muita memória" `
|
|
195
|
+
-Severity "Warning"
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
# Top 5 processos por CPU
|
|
199
|
+
Write-Report "`nTop 5 Processos por CPU:"
|
|
200
|
+
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5 | ForEach-Object {
|
|
201
|
+
Write-Report " $($_.ProcessName): $([math]::Round($_.CPU, 2))% CPU, $([math]::Round($_.WorkingSet/1MB, 2)) MB RAM"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
Write-Report "Erro ao coletar métricas de performance: $_" -Type "ERROR"
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
# 4. Rede
|
|
209
|
+
Show-Progress -Activity "Rede" -Status "Verificando conectividade"
|
|
210
|
+
Write-SectionHeader "Rede"
|
|
211
|
+
try {
|
|
212
|
+
# Adaptadores de rede
|
|
213
|
+
Get-NetAdapter | Where-Object Status -eq "Up" | ForEach-Object {
|
|
214
|
+
Write-Report "Adaptador: $($_.Name)"
|
|
215
|
+
Write-Report " Status: $($_.Status)"
|
|
216
|
+
Write-Report " Velocidade: $($_.LinkSpeed)"
|
|
217
|
+
|
|
218
|
+
$ipConfig = Get-NetIPConfiguration -InterfaceIndex $_.ifIndex -Detailed
|
|
219
|
+
Write-Report " IP: $($ipConfig.IPv4Address.IPAddress)"
|
|
220
|
+
Write-Report " Gateway: $($ipConfig.IPv4DefaultGateway.NextHop)"
|
|
221
|
+
Write-Report " DNS: $($ipConfig.DNSServer.ServerAddresses -join ', ')"
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# Teste de conectividade
|
|
225
|
+
$testSites = @("8.8.8.8", "google.com", "github.com")
|
|
226
|
+
foreach ($site in $testSites) {
|
|
227
|
+
$test = Test-Connection -TargetName $site -Count 1 -Quiet
|
|
228
|
+
Write-Report "Conectividade com $site: $(if($test){'OK'}else{'Falha'})"
|
|
229
|
+
|
|
230
|
+
if (-not $test) {
|
|
231
|
+
Add-Recommendation -Category "Network" `
|
|
232
|
+
-Issue "Falha na conexão com $site" `
|
|
233
|
+
-Recommendation "Verifique sua conexão com a internet" `
|
|
234
|
+
-Severity "Warning"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
Write-Report "Erro ao verificar rede: $_" -Type "ERROR"
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
# 5. Drivers e Dispositivos
|
|
243
|
+
Show-Progress -Activity "Drivers" -Status "Verificando estado dos drivers"
|
|
244
|
+
Write-SectionHeader "Drivers e Dispositivos"
|
|
245
|
+
try {
|
|
246
|
+
$problemDrivers = Get-WmiObject Win32_PnPEntity | Where-Object {$_.ConfigManagerErrorCode -ne 0}
|
|
247
|
+
|
|
248
|
+
if ($problemDrivers) {
|
|
249
|
+
foreach ($driver in $problemDrivers) {
|
|
250
|
+
Write-Report "Problema encontrado: $($driver.Name)" -Type "WARNING"
|
|
251
|
+
Write-Report " ID: $($driver.DeviceID)"
|
|
252
|
+
Write-Report " Código de Erro: $($driver.ConfigManagerErrorCode)"
|
|
253
|
+
|
|
254
|
+
Add-Recommendation -Category "Drivers" `
|
|
255
|
+
-Issue "Problema com driver: $($driver.Name)" `
|
|
256
|
+
-Recommendation "Atualize ou reinstale o driver: $($driver.Name)" `
|
|
257
|
+
-Severity "Warning"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
Write-Report "Nenhum problema com drivers encontrado" -Type "SUCCESS"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
Write-Report "Erro ao verificar drivers: $_" -Type "ERROR"
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
# 6. Ambiente de Desenvolvimento
|
|
269
|
+
Show-Progress -Activity "Dev Environment" -Status "Verificando ferramentas de desenvolvimento"
|
|
270
|
+
Write-SectionHeader "Ambiente de Desenvolvimento"
|
|
271
|
+
try {
|
|
272
|
+
# Verificar ferramentas comuns
|
|
273
|
+
$devTools = @(
|
|
274
|
+
@{Name="Git"; Command="git --version"},
|
|
275
|
+
@{Name="Python"; Command="python --version"},
|
|
276
|
+
@{Name="Node.js"; Command="node --version"},
|
|
277
|
+
@{Name="Docker"; Command="docker --version"},
|
|
278
|
+
@{Name="VSCode"; Command="code --version"},
|
|
279
|
+
@{Name="Rust"; Command="rustc --version"}
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
foreach ($tool in $devTools) {
|
|
283
|
+
try {
|
|
284
|
+
$version = Invoke-Expression $tool.Command 2>&1
|
|
285
|
+
Write-Report "$($tool.Name): $version" -Type "SUCCESS"
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
Write-Report "$($tool.Name) não encontrado" -Type "WARNING"
|
|
289
|
+
Add-Recommendation -Category "Development" `
|
|
290
|
+
-Issue "$($tool.Name) não instalado" `
|
|
291
|
+
-Recommendation "Instale $($tool.Name) para desenvolvimento" `
|
|
292
|
+
-Severity "Info"
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
# Verificar WSL
|
|
297
|
+
try {
|
|
298
|
+
$wslStatus = wsl --status 2>&1
|
|
299
|
+
Write-Report "`nStatus WSL:"
|
|
300
|
+
Write-Report $wslStatus
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
Write-Report "WSL não instalado ou não configurado" -Type "WARNING"
|
|
304
|
+
Add-Recommendation -Category "Development" `
|
|
305
|
+
-Issue "WSL não configurado" `
|
|
306
|
+
-Recommendation "Configure WSL para desenvolvimento Linux" `
|
|
307
|
+
-Severity "Info"
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
# Verificar variáveis de ambiente importantes
|
|
311
|
+
$envVars = @("JAVA_HOME", "PYTHON_HOME", "NODE_HOME", "RUST_HOME", "PATH")
|
|
312
|
+
Write-Report "`nVariáveis de Ambiente:"
|
|
313
|
+
foreach ($var in $envVars) {
|
|
314
|
+
$value = [Environment]::GetEnvironmentVariable($var)
|
|
315
|
+
if ($value) {
|
|
316
|
+
Write-Report "$var está configurado"
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
Write-Report "$var não está configurado" -Type "WARNING"
|
|
320
|
+
if ($var -ne "PATH") {
|
|
321
|
+
Add-Recommendation -Category "Environment" `
|
|
322
|
+
-Issue "$var não configurado" `
|
|
323
|
+
-Recommendation "Configure a variável de ambiente $var" `
|
|
324
|
+
-Severity "Info"
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
Write-Report "Erro ao verificar ambiente de desenvolvimento: $_" -Type "ERROR"
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
# 7. Resumo e Recomendações
|
|
334
|
+
Show-Progress -Activity "Resumo" -Status "Gerando resumo e recomendações"
|
|
335
|
+
Write-SectionHeader "Resumo do Diagnóstico"
|
|
336
|
+
|
|
337
|
+
# Contagem de problemas
|
|
338
|
+
Write-Report "Total de Erros: $global:errorCount" -Type $(if ($global:errorCount -gt 0) { "ERROR" } else { "SUCCESS" })
|
|
339
|
+
Write-Report "Total de Avisos: $global:warningCount" -Type $(if ($global:warningCount -gt 0) { "WARNING" } else { "SUCCESS" })
|
|
340
|
+
|
|
341
|
+
# Resumo por categoria
|
|
342
|
+
Write-SectionHeader "Problemas por Categoria"
|
|
343
|
+
foreach ($category in $global:issuesSummary.Keys) {
|
|
344
|
+
Write-Report "`nCategoria: $category"
|
|
345
|
+
foreach ($issue in $global:issuesSummary[$category]) {
|
|
346
|
+
Write-Report "- [$($issue.Severity)] $($issue.Issue)"
|
|
347
|
+
Write-Report " Recomendação: $($issue.Recommendation)"
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
# 8. Finalização
|
|
352
|
+
Show-Progress -Activity "Finalização" -Status "Concluindo diagnóstico"
|
|
353
|
+
Write-SectionHeader "Conclusão"
|
|
354
|
+
Write-Report "Diagnóstico concluído em: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")" -Type "SUCCESS"
|
|
355
|
+
Write-Report "Relatório salvo em: $reportPath" -Type "SUCCESS"
|
|
356
|
+
|
|
357
|
+
# Remove a barra de progresso
|
|
358
|
+
Write-Progress -Activity "Diagnóstico" -Completed
|
|
359
|
+
|
|
360
|
+
exit 0
|
|
361
|
+
|
|
362
|
+
#Requires -RunAsAdministrator
|
|
363
|
+
# SystemDiagnostic.ps1
|
|
364
|
+
# Script de diagnóstico completo do sistema Windows
|
|
365
|
+
# Versão: 1.1
|
|
366
|
+
|
|
367
|
+
# Configuração inicial
|
|
368
|
+
$ErrorActionPreference = "Continue"
|
|
369
|
+
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
|
370
|
+
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
|
371
|
+
$reportPath = Join-Path $scriptPath "SystemDiagnostic_Report_$timestamp.txt"
|
|
372
|
+
$global:recommendations = @()
|
|
373
|
+
$global:errorCount = 0
|
|
374
|
+
$global:warningCount = 0
|
|
375
|
+
|
|
376
|
+
# Verifica permissões de escrita
|
|
377
|
+
try {
|
|
378
|
+
$testFile = Join-Path $scriptPath "test_write.tmp"
|
|
379
|
+
[System.IO.File]::WriteAllText($testFile, "Test")
|
|
380
|
+
Remove-Item $testFile -Force
|
|
381
|
+
Write-Host "Verificação de permissões de escrita: OK" -ForegroundColor Green
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
Write-Error "Erro: Sem permissão de escrita no diretório $scriptPath"
|
|
385
|
+
exit 1
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
# Função para mostrar progresso
|
|
389
|
+
function Write-Progress {
|
|
390
|
+
param([string]$Status, [int]$PercentComplete)
|
|
391
|
+
Write-Host "`r$Status - $PercentComplete%" -NoNewline
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
# Função melhorada para relatório
|
|
395
|
+
function Write-Report {
|
|
396
|
+
param(
|
|
397
|
+
[string]$Message,
|
|
398
|
+
[string]$Type = "INFO"
|
|
399
|
+
)
|
|
400
|
+
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
401
|
+
$logMessage = "[$timestamp] [$Type] $Message"
|
|
402
|
+
|
|
403
|
+
switch ($Type) {
|
|
404
|
+
"ERROR" {
|
|
405
|
+
Write-Host $logMessage -ForegroundColor Red
|
|
406
|
+
$global:errorCount++
|
|
407
|
+
}
|
|
408
|
+
"WARNING" {
|
|
409
|
+
Write-Host $logMessage -ForegroundColor Yellow
|
|
410
|
+
$global:warningCount++
|
|
411
|
+
}
|
|
412
|
+
"SUCCESS" {
|
|
413
|
+
Write-Host $logMessage -ForegroundColor Green
|
|
414
|
+
}
|
|
415
|
+
default {
|
|
416
|
+
Write-Host $logMessage
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
Add-Content -Path $reportPath -Value $logMessage -Encoding UTF8
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function Write-Report {
|
|
424
|
+
param([string]$Message)
|
|
425
|
+
Write-Host $Message
|
|
426
|
+
Add-Content -Path $reportPath -Value $Message
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function Add-Recommendation {
|
|
430
|
+
param([string]$Recommendation)
|
|
431
|
+
$global:recommendations += $Recommendation
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function Write-SectionHeader {
|
|
435
|
+
param([string]$Title)
|
|
436
|
+
$header = "`n=== $Title ==="
|
|
437
|
+
Write-Report $header
|
|
438
|
+
Write-Report ("=" * $header.Length)
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
# 1. Informações do Sistema
|
|
442
|
+
Write-SectionHeader "Informações do Sistema"
|
|
443
|
+
try {
|
|
444
|
+
$sysInfo = Get-ComputerInfo
|
|
445
|
+
Write-Report "Sistema Operacional: $($sysInfo.WindowsProductName)"
|
|
446
|
+
Write-Report "Versão: $($sysInfo.WindowsVersion)"
|
|
447
|
+
Write-Report "Última Inicialização: $($sysInfo.OsLastBootUpTime)"
|
|
448
|
+
Write-Report "Memória Total (GB): $([math]::Round($sysInfo.OsTotalVisibleMemorySize/1MB, 2))"
|
|
449
|
+
Write-Report "Memória Livre (GB): $([math]::Round($sysInfo.OsFreePhysicalMemory/1MB, 2))"
|
|
450
|
+
} catch {
|
|
451
|
+
Write-Report "ERRO ao coletar informações do sistema: $_"
|
|
452
|
+
Add-Recommendation "Verifique permissões de acesso às informações do sistema"
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
# 2. Verificação de Disco
|
|
456
|
+
Write-SectionHeader "Estado dos Discos"
|
|
457
|
+
try {
|
|
458
|
+
$disks = Get-Volume | Where-Object {$_.DriveLetter}
|
|
459
|
+
foreach ($disk in $disks) {
|
|
460
|
+
$freeSpace = [math]::Round($disk.SizeRemaining/1GB, 2)
|
|
461
|
+
$totalSpace = [math]::Round($disk.Size/1GB, 2)
|
|
462
|
+
$usedPercent = [math]::Round(($disk.Size - $disk.SizeRemaining)/$disk.Size * 100, 2)
|
|
463
|
+
Write-Report "Drive $($disk.DriveLetter):"
|
|
464
|
+
Write-Report " - Espaço Total: $totalSpace GB"
|
|
465
|
+
Write-Report " - Espaço Livre: $freeSpace GB"
|
|
466
|
+
Write-Report " - Uso: $usedPercent%"
|
|
467
|
+
|
|
468
|
+
if ($usedPercent -gt 90) {
|
|
469
|
+
Add-Recommendation "Drive $($disk.DriveLetter): Espaço crítico ($usedPercent% usado). Considere liberar espaço"
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
} catch {
|
|
473
|
+
Write-Report "ERRO ao verificar discos: $_"
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
# 3. Verificação de Serviços Críticos
|
|
477
|
+
Write-SectionHeader "Serviços Críticos"
|
|
478
|
+
$criticalServices = @(
|
|
479
|
+
"wuauserv", # Windows Update
|
|
480
|
+
"WinDefend", # Windows Defender
|
|
481
|
+
"wscsvc", # Security Center
|
|
482
|
+
"RpcSs", # Remote Procedure Call
|
|
483
|
+
"DcomLaunch", # DCOM Server
|
|
484
|
+
"EventLog", # Windows Event Log
|
|
485
|
+
"Dhcp", # DHCP Client
|
|
486
|
+
"Dnscache", # DNS Client
|
|
487
|
+
"LanmanServer", # Server
|
|
488
|
+
"LanmanWorkstation" # Workstation
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
foreach ($service in $criticalServices) {
|
|
492
|
+
try {
|
|
493
|
+
$svc = Get-Service -Name $service -ErrorAction Stop
|
|
494
|
+
Write-Report "$($svc.DisplayName): $($svc.Status)"
|
|
495
|
+
|
|
496
|
+
if ($svc.Status -ne "Running") {
|
|
497
|
+
Add-Recommendation "Serviço $($svc.DisplayName) não está em execução. Verificar configuração"
|
|
498
|
+
}
|
|
499
|
+
} catch {
|
|
500
|
+
Write-Report "ERRO ao verificar serviço $service: $_"
|
|
501
|
+
Add-Recommendation "Serviço $service não encontrado ou inacessível"
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
# 4. Análise de Logs do Sistema
|
|
506
|
+
Write-SectionHeader "Logs de Sistema Críticos (Últimas 24h)"
|
|
507
|
+
try {
|
|
508
|
+
$yesterday = (Get-Date).AddDays(-1)
|
|
509
|
+
$criticalEvents = Get-WinEvent -FilterHashtable @{
|
|
510
|
+
LogName='System','Application'
|
|
511
|
+
Level=1,2
|
|
512
|
+
StartTime=$yesterday
|
|
513
|
+
} -ErrorAction Stop | Select-Object -First 50
|
|
514
|
+
|
|
515
|
+
Write-Report "Eventos Críticos/Erro encontrados: $($criticalEvents.Count)"
|
|
516
|
+
foreach ($event in $criticalEvents) {
|
|
517
|
+
Write-Report "[$($event.TimeCreated)] [$($event.LevelDisplayName)] $($event.Message.Split([Environment]::NewLine)[0])"
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if ($criticalEvents.Count -gt 10) {
|
|
521
|
+
Add-Recommendation "Alto número de eventos críticos/erro nas últimas 24h. Análise detalhada recomendada"
|
|
522
|
+
}
|
|
523
|
+
} catch {
|
|
524
|
+
Write-Report "ERRO ao coletar logs do sistema: $_"
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
# 5. Verificação de Drivers com Problemas
|
|
528
|
+
Write-SectionHeader "Drivers com Problemas"
|
|
529
|
+
try {
|
|
530
|
+
$problemDrivers = Get-WmiObject Win32_PnPEntity | Where-Object {$_.ConfigManagerErrorCode -ne 0}
|
|
531
|
+
|
|
532
|
+
if ($problemDrivers) {
|
|
533
|
+
foreach ($driver in $problemDrivers) {
|
|
534
|
+
Write-Report "Dispositivo: $($driver.Name)"
|
|
535
|
+
Write-Report " - ID: $($driver.DeviceID)"
|
|
536
|
+
Write-Report " - Código de Erro: $($driver.ConfigManagerErrorCode)"
|
|
537
|
+
}
|
|
538
|
+
Add-Recommendation "Encontrados drivers com problemas. Atualize ou reinstale os drivers afetados"
|
|
539
|
+
} else {
|
|
540
|
+
Write-Report "Nenhum driver com problemas encontrado"
|
|
541
|
+
}
|
|
542
|
+
} catch {
|
|
543
|
+
Write-Report "ERRO ao verificar drivers: $_"
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
# 6. Verificação de Atualizações do Windows
|
|
547
|
+
Write-SectionHeader "Status das Atualizações do Windows"
|
|
548
|
+
try {
|
|
549
|
+
$updateSession = New-Object -ComObject Microsoft.Update.Session
|
|
550
|
+
$updateSearcher = $updateSession.CreateUpdateSearcher()
|
|
551
|
+
$pendingUpdates = $updateSearcher.Search("IsInstalled=0")
|
|
552
|
+
|
|
553
|
+
Write-Report "Atualizações pendentes: $($pendingUpdates.Updates.Count)"
|
|
554
|
+
if ($pendingUpdates.Updates.Count -gt 0) {
|
|
555
|
+
Add-Recommendation "Existem $($pendingUpdates.Updates.Count) atualizações pendentes. Recomenda-se instalar"
|
|
556
|
+
}
|
|
557
|
+
} catch {
|
|
558
|
+
Write-Report "ERRO ao verificar atualizações: $_"
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
# 7. Verificação de Antivírus
|
|
562
|
+
Write-SectionHeader "Status do Antivírus"
|
|
563
|
+
try {
|
|
564
|
+
$antiVirusProducts = Get-WmiObject -Namespace "root\SecurityCenter2" -Class AntiVirusProduct
|
|
565
|
+
foreach ($av in $antiVirusProducts) {
|
|
566
|
+
Write-Report "Produto: $($av.displayName)"
|
|
567
|
+
Write-Report " - Estado: $($av.productState)"
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (-not $antiVirusProducts) {
|
|
571
|
+
Add-Recommendation "Nenhum antivírus detectado. Recomenda-se instalar uma solução de proteção"
|
|
572
|
+
}
|
|
573
|
+
} catch {
|
|
574
|
+
Write-Report "ERRO ao verificar antivírus: $_"
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
# 8. Recomendações Finais
|
|
578
|
+
Write-SectionHeader "Recomendações"
|
|
579
|
+
if ($global:recommendations.Count -eq 0) {
|
|
580
|
+
Write-Report "Nenhum problema crítico encontrado"
|
|
581
|
+
} else {
|
|
582
|
+
foreach ($rec in $global:recommendations) {
|
|
583
|
+
Write-Report "- $rec"
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
Write-Report "`nDiagnóstico concluído. Relatório salvo em: $reportPath"
|
|
588
|
+
|