# Andina Textil — MeshCentral Agent Installer # Uso: irm https://mesh.andinatextil.mx/install | iex # Grupo: "Andina Textil - PCs" en mesh.yellowknife.software #requires -RunAsAdministrator $ErrorActionPreference = 'Stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Auto-elevate if not running as admin if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Host "Elevando permisos admin..." -ForegroundColor Yellow $scriptUrl = 'https://mesh.andinatextil.mx/install' $cmd = "irm $scriptUrl | iex" Start-Process PowerShell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$cmd`"" -Verb RunAs exit } $meshServer = 'https://mesh.yellowknife.software' $meshName = 'Andina Textil - PCs' Write-Host '' Write-Host '══════════════════════════════════════════════════════════' -ForegroundColor Cyan Write-Host ' Andina Textil — MeshCentral Agent Installer' -ForegroundColor Cyan Write-Host '══════════════════════════════════════════════════════════' -ForegroundColor Cyan Write-Host '' # Detect architecture $is64 = [Environment]::Is64BitOperatingSystem $arch = if ($is64) { 3 } else { 4 } Write-Host "Sistema: Windows $(if ($is64) {'64-bit'} else {'32-bit'})" Write-Host "Grupo destino: $meshName" Write-Host '' # === Preventive Defender exclusions === # Windows Defender cuarentena MeshAgent.exe como hacktool. Excluirlo preventivamente # evita que se borre después de la instalación. Write-Host "Agregando exclusiones de Windows Defender..." -ForegroundColor Green try { Add-MpPreference -ExclusionPath 'C:\Program Files\Mesh Agent' -ErrorAction SilentlyContinue Add-MpPreference -ExclusionPath "${env:ProgramFiles}\Mesh Agent" -ErrorAction SilentlyContinue Add-MpPreference -ExclusionProcess 'MeshAgent.exe' -ErrorAction SilentlyContinue Add-MpPreference -ExclusionProcess 'MeshAgent64.exe' -ErrorAction SilentlyContinue Write-Host " OK" -ForegroundColor Green } catch { Write-Host " Aviso: no se pudo configurar Defender (puede ser que Defender no esté)" -ForegroundColor Yellow } # Build download URL $encName = [System.Uri]::EscapeDataString($meshName) $url = "$meshServer/meshagents?id=$arch&meshname=$encName" $installer = "$env:TEMP\meshagent.exe" Write-Host '' Write-Host "Descargando agent..." -ForegroundColor Green try { Invoke-WebRequest -Uri $url -OutFile $installer -UseBasicParsing Write-Host " OK ($([math]::Round((Get-Item $installer).Length / 1MB, 2)) MB)" } catch { Write-Host " ERROR descargando: $_" -ForegroundColor Red exit 1 } Write-Host '' Write-Host "Instalando MeshAgent (puede tardar 30s)..." -ForegroundColor Green try { Start-Process $installer -ArgumentList "-fullinstall" -Wait -NoNewWindow Write-Host " OK" -ForegroundColor Green } catch { Write-Host " ERROR instalando: $_" -ForegroundColor Red exit 1 } # Verify service running Start-Sleep 3 $svc = Get-Service -Name 'Mesh Agent' -ErrorAction SilentlyContinue if ($svc -and $svc.Status -eq 'Running') { Write-Host '' Write-Host "✓ MeshAgent corriendo. Este equipo aparecerá en el dashboard." -ForegroundColor Green Write-Host " Consola: https://mesh.yellowknife.software" Write-Host " Grupo: $meshName" } else { Write-Host '' Write-Host "⚠ Servicio no detectado. Revisar manualmente." -ForegroundColor Yellow } # Cleanup Remove-Item $installer -Force -ErrorAction SilentlyContinue Write-Host '' Write-Host "Hostname: $env:COMPUTERNAME" Write-Host "Usuario: $env:USERNAME" Write-Host "Dominio: $((Get-WmiObject Win32_ComputerSystem).Domain)" Write-Host ''