docs: optimize ADN system, resolve Proxmox cluster SSH, implement DASU VPN bypass, and automate Posgrado calendar import
This commit is contained in:
+77
-44
@@ -1,61 +1,94 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sonda de Relevamiento para Nodos Windows (Compatible con Agente srv-NS8)
|
||||
Versión: 1.0.0
|
||||
Autor: Ricardo MONLA (Generado por Agente)
|
||||
|
||||
.DESCRIPTION
|
||||
Recopila información de hardware, red y software para generar un perfil JSON compatible.
|
||||
.USAGE
|
||||
Recolecta información de Hardware, Red, Sistema Operativo y Servicios.
|
||||
Genera un objeto JSON compatible con la Ontología del proyecto.
|
||||
|
||||
.EXAMPLE
|
||||
.\sonda_windows.ps1
|
||||
#>
|
||||
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
|
||||
# --- 1. System Info ---
|
||||
# --- 1. Sistema Operativo ---
|
||||
$os = Get-CimInstance Win32_OperatingSystem
|
||||
$cs = Get-CimInstance Win32_ComputerSystem
|
||||
$cpu = Get-CimInstance Win32_Processor
|
||||
$mem = Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum
|
||||
|
||||
# --- 2. Network ---
|
||||
$net = Get-NetIPAddress | Where-Object { $_.AddressFamily -eq 'IPv4' -and $_.InterfaceAlias -notlike '*Loopback*' } | Select-Object IPAddress, InterfaceAlias
|
||||
# --- 2. Hardware: CPU ---
|
||||
$cpu = Get-CimInstance Win32_Processor | Select-Object -First 1
|
||||
$cpuName = $cpu.Name.Trim()
|
||||
$cores = $cpu.NumberOfCores
|
||||
$threads = $cpu.NumberOfLogicalProcessors
|
||||
|
||||
# --- 3. Disks ---
|
||||
$disks = Get-PhysicalDisk | Select-Object FriendlyName, MediaType, Size
|
||||
# --- 3. Hardware: RAM ---
|
||||
$ramBytes = $cs.TotalPhysicalMemory
|
||||
$ramGB = [Math]::Round($ramBytes / 1GB, 2)
|
||||
|
||||
# --- 4. Software (Specific Checks) ---
|
||||
$anydesk = Get-Process -Name "AnyDesk" -ErrorAction SilentlyContinue
|
||||
$tailscale = Get-Service -Name "Tailscale" -ErrorAction SilentlyContinue
|
||||
|
||||
# --- Construct JSON ---
|
||||
$payload = @{
|
||||
timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss zzz")
|
||||
connector = @{
|
||||
hostname_detected = $env:COMPUTERNAME
|
||||
user = $env:USERNAME
|
||||
platorm = "Windows"
|
||||
}
|
||||
cpu = @{
|
||||
model = $cpu.Name
|
||||
cores = $cpu.NumberOfCores
|
||||
arch = $os.OSArchitecture
|
||||
}
|
||||
ram = @{
|
||||
total_gb = [math]::Round($mem.Sum / 1GB, 2)
|
||||
raw = $mem.Sum
|
||||
}
|
||||
os = @{
|
||||
edition = $os.Caption
|
||||
version = $os.Version
|
||||
build = $os.BuildNumber
|
||||
}
|
||||
network = $net
|
||||
disks = $disks
|
||||
services = @{
|
||||
anydesk_running = [bool]$anydesk
|
||||
tailscale_status = if ($tailscale) { $tailscale.Status } else { "Not Installed" }
|
||||
# --- 4. Hardware: Discos ---
|
||||
$disks = Get-CimInstance Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 } | ForEach-Object {
|
||||
@{
|
||||
id = $_.DeviceID
|
||||
size_gb = [Math]::Round($_.Size / 1GB, 2)
|
||||
used_gb = [Math]::Round(($_.Size - $_.FreeSpace) / 1GB, 2)
|
||||
free_gb = [Math]::Round($_.FreeSpace / 1GB, 2)
|
||||
fs_type = $_.FileSystem
|
||||
mount_point = $_.DeviceID
|
||||
}
|
||||
}
|
||||
|
||||
# --- Output ---
|
||||
Write-Host "---START_PAYLOAD---" -ForegroundColor Cyan
|
||||
$payload | ConvertTo-Json -Depth 3
|
||||
Write-Host "---END_PAYLOAD---" -ForegroundColor Cyan
|
||||
# --- 5. Red ---
|
||||
$netAdapters = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' } | ForEach-Object {
|
||||
$ipInfo = Get-NetIPAddress -InterfaceAlias $_.Name -AddressFamily IPv4 | Select-Object -First 1
|
||||
@{
|
||||
interface = $_.Name
|
||||
mac = $_.MacAddress
|
||||
ip = if ($ipInfo) { $ipInfo.IPAddress } else { "N/A" }
|
||||
state = "UP"
|
||||
speed_mbps = [Math]::Round($_.LinkSpeed / 1MB, 0)
|
||||
}
|
||||
}
|
||||
|
||||
# --- 6. Software Detectado (Servicios Clave) ---
|
||||
$servicesToCheck = @("Tailscale", "RustDesk", "AnyDesk", "TeamViewer", "ssh-agent", "sshd")
|
||||
$detectedServices = Get-Service | Where-Object { $servicesToCheck -contains $_.Name -or $servicesToCheck -contains $_.DisplayName } | ForEach-Object {
|
||||
@{
|
||||
name = $_.Name
|
||||
status = $_.Status.ToString()
|
||||
startup = $_.StartType.ToString()
|
||||
}
|
||||
}
|
||||
|
||||
# --- 7. Construcción del JSON ---
|
||||
$sondaData = @{
|
||||
timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
|
||||
node = @{
|
||||
hostname = $cs.DNSHostName
|
||||
os = "$($os.Caption) ($($os.OSArchitecture))"
|
||||
version = $os.Version
|
||||
domain = $cs.Domain
|
||||
model = $cs.Model
|
||||
}
|
||||
hardware = @{
|
||||
cpu = @{
|
||||
model = $cpuName
|
||||
cores = $cores
|
||||
threads = $threads
|
||||
}
|
||||
ram_gb = $ramGB
|
||||
disks = $disks
|
||||
}
|
||||
network = $netAdapters
|
||||
services = $detectedServices
|
||||
meta = @{
|
||||
agent_version = "1.0.0-win"
|
||||
type = "probe_windows"
|
||||
}
|
||||
}
|
||||
|
||||
# --- 8. Salida ---
|
||||
$jsonOutput = $sondaData | ConvertTo-Json -Depth 5
|
||||
Write-Output $jsonOutput
|
||||
|
||||
Reference in New Issue
Block a user