# ============================================================================= # Diagnostica Windows - Strumento avanzato con GUI WPF # Compatibile con Windows 10 e Windows 11 # # Avvio rapido (da PowerShell normale, non serve admin): # irm https://get.23022.it | iex # # Lo script si auto-eleva via UAC e si rilancia con -ExecutionPolicy Bypass # Nessuna modifica permanente al sistema (eccetto reset rete su richiesta) # ============================================================================= # ---- Auto-bootstrap: garantisce admin + STA + Bypass policy ---------------- $ScriptUrl = 'https://get.23022.it' $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator) $isStaThread = ([Threading.Thread]::CurrentThread.GetApartmentState() -eq 'STA') if (-not $isAdmin -or -not $isStaThread) { Write-Host "" Write-Host " Diagnostica Windows" -ForegroundColor Cyan if (-not $isAdmin) { Write-Host " Richiesta elevazione amministratore via UAC..." -ForegroundColor Gray } else { Write-Host " Riavvio in modalita STA (richiesto per WPF)..." -ForegroundColor Gray } Write-Host "" $tempPath = Join-Path $env:TEMP ("Diagnostica-Windows-{0}.ps1" -f ([Guid]::NewGuid().ToString('N').Substring(0,8))) try { $oldTls = [Net.ServicePointManager]::SecurityProtocol [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Invoke-RestMethod -Uri $ScriptUrl -OutFile $tempPath -UseBasicParsing -ErrorAction Stop [Net.ServicePointManager]::SecurityProtocol = $oldTls } catch { Write-Host (" Impossibile scaricare lo script da " + $ScriptUrl) -ForegroundColor Red Write-Host (" " + $_.Exception.Message) -ForegroundColor Red Write-Host "" Read-Host "Premi INVIO per chiudere" return } $argList = @( '-NoProfile' '-ExecutionPolicy', 'Bypass' '-STA' '-WindowStyle', 'Hidden' '-File', ('"' + $tempPath + '"') ) try { if (-not $isAdmin) { Start-Process -FilePath 'powershell.exe' -ArgumentList $argList -Verb RunAs -ErrorAction Stop } else { Start-Process -FilePath 'powershell.exe' -ArgumentList $argList -ErrorAction Stop } } catch { Write-Host " Elevazione annullata dall'utente." -ForegroundColor Yellow } return } # ---------------------------------------------------------------------------- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8 $ErrorActionPreference = 'Continue' Add-Type -AssemblyName PresentationFramework Add-Type -AssemblyName PresentationCore Add-Type -AssemblyName WindowsBase Add-Type -AssemblyName System.Windows.Forms # ----------------------------------------------------------------------------- # XAML - definizione interfaccia # ----------------------------------------------------------------------------- [xml]$xaml = @'