Last active
July 1, 2026 17:36
-
-
Save davidlares/1af9a501914dad61e1cab1b96f6a7aac to your computer and use it in GitHub Desktop.
Specs inventory wrapper collector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -Version 5.1 | |
| <# | |
| .SYNOPSIS | |
| Recopila las especificaciones de hardware y del sistema operativo de la máquina local | |
| y las guarda en un archivo CSV. | |
| .DESCRIPTION | |
| Script de ejecución para la evaluacion técnica de cada estación de trabajo. | |
| No se requiere acceso a la red ni conectividad al dominio. | |
| #> | |
| $OutputPath = Join-Path -Path $PSScriptRoot -ChildPath "$env:COMPUTERNAME.csv" | |
| # Objeto WMI | |
| function Get-WmiSafe { | |
| param($Class, $NS = "root\cimv2") | |
| try { Get-WmiObject -Class $Class -Namespace $NS -ErrorAction Stop } | |
| catch { $null } | |
| } | |
| Write-Host "" | |
| Write-Host " Inventario de Hardware [Util]" -ForegroundColor Cyan | |
| Write-Host " Equipo: $env:COMPUTERNAME" -ForegroundColor Cyan | |
| Write-Host "" | |
| # S.O e identidad | |
| Write-Host " [1/8] S.O e identidad" -NoNewline | |
| $os = Get-WmiSafe Win32_OperatingSystem | |
| $cs = Get-WmiSafe Win32_ComputerSystem | |
| $bios = Get-WmiSafe Win32_BIOS | |
| $lastUser = (Get-ItemProperty ` "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" ` -ErrorAction SilentlyContinue).LastLoggedOnUser | |
| $lastBoot = $os.ConvertToDateTime($os.LastBootUpTime) | |
| $uptime = [math]::Round(((Get-Date) - $lastBoot).TotalDays, 1) | |
| Write-Host " OK" -ForegroundColor Green | |
| # Sistema y BIOS | |
| Write-Host " [2/8] Sistema y BIOS" -NoNewline | |
| $biosDate = try { $bios.ConvertToDateTime($bios.ReleaseDate).ToString("yyyy-MM-dd") } catch { "N/A" } | |
| Write-Host " OK" -ForegroundColor Green | |
| # CPU | |
| Write-Host " [3/8] CPU" -NoNewline | |
| $cpu = Get-WmiSafe Win32_Processor | Select-Object -First 1 | |
| Write-Host " OK" -ForegroundColor Green | |
| # RAM | |
| Write-Host " [4/8] RAM" -NoNewline | |
| $ramModules = Get-WmiSafe Win32_PhysicalMemory | |
| $ramTotalGB = [math]::Round(($ramModules | Measure-Object -Property Capacity -Sum).Sum / 1GB, 1) | |
| $ramType = switch (($ramModules | Select-Object -First 1).MemoryType) { | |
| 20{"DDR"} 21{"DDR2"} 24{"DDR3"} 26{"DDR4"} 34{"DDR5"} default{"Unknown"} | |
| } | |
| Write-Host " OK" -ForegroundColor Green | |
| # Almacenamiento | |
| Write-Host " [5/8] Almacenamiento" -NoNewline | |
| $physDisks = (Get-WmiSafe Win32_DiskDrive) | ForEach-Object { | |
| $sGB = [math]::Round($_.Size / 1GB, 1) | |
| $type = if ($_.Model -match "NVMe|SSD") { "SSD" } | |
| elseif ($_.MediaType -match "SSD|Solid") { "SSD" } | |
| else { "HDD" } | |
| "$($_.Model.Trim()) [$sGB GB, $type]" | |
| } | |
| $logDisks = (Get-WmiSafe Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 }) | ForEach-Object { | |
| "$($_.DeviceID) $([math]::Round($_.Size/1GB,1))GB (Free: $([math]::Round($_.FreeSpace/1GB,1))GB)" | |
| } | |
| Write-Host " OK" -ForegroundColor Green | |
| # GPU | |
| Write-Host " [6/8] GPU" -NoNewline | |
| $gpuInfo = (Get-WmiSafe Win32_VideoController) | ForEach-Object { | |
| $vram = if ($_.AdapterRAM) { "$([math]::Round($_.AdapterRAM/1MB))MB" } else { "N/A" } | |
| "$($_.Name.Trim()) [$vram VRAM]" | |
| } | |
| Write-Host " OK" -ForegroundColor Green | |
| # Red | |
| Write-Host " [7/8] Adaptadores de red" -NoNewline | |
| $nicInfo = (Get-WmiSafe Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled }) | ForEach-Object { | |
| $ip = ($_.IPAddress | Where-Object { $_ -match '^\d{1,3}\.' }) -join "," | |
| "$($_.Description.Trim()) | MAC: $($_.MACAddress) | IP: $ip" | |
| } | |
| Write-Host " OK" -ForegroundColor Green | |
| # Windows | |
| Write-Host " [8/8] Estado del O.S" -NoNewline | |
| $activation = try { | |
| $lic = Get-WmiObject SoftwareLicensingProduct -ErrorAction Stop | | |
| Where-Object { $_.Name -match "Windows" -and $_.PartialProductKey } | |
| switch ($lic.LicenseStatus) { | |
| 1{"Licensed"} 2{"OOBGrace"} 3{"OOTGrace"} 4{"NonGenuine"} 5{"Unlicensed"} default{"Unknown"} | |
| } | |
| } catch { "N/A" } | |
| Write-Host " OK" -ForegroundColor Green | |
| # Exportar CSV | |
| $row = [PSCustomObject]@{ | |
| CollectedAt = (Get-Date).ToString("yyyy-MM-dd HH:mm") | |
| Hostname = $env:COMPUTERNAME | |
| Domain = $cs.Domain | |
| LastLoggedOnUser = $lastUser | |
| Manufacturer = $cs.Manufacturer | |
| Model = $cs.Model | |
| SerialNumber = $bios.SerialNumber | |
| BIOSVersion = $bios.SMBIOSBIOSVersion | |
| BIOSDate = $biosDate | |
| OS = $os.Caption | |
| OSVersion = $os.Version | |
| OSBuild = $os.BuildNumber | |
| OSArch = $os.OSArchitecture | |
| Activation = $activation | |
| LastBoot = $lastBoot.ToString("yyyy-MM-dd HH:mm") | |
| UptimeDays = $uptime | |
| CPU = $cpu.Name.Trim() | |
| CPU_Cores = $cpu.NumberOfCores | |
| CPU_LogicalProcs = $cpu.NumberOfLogicalProcessors | |
| CPU_SpeedMHz = $cpu.MaxClockSpeed | |
| RAM_TotalGB = $ramTotalGB | |
| RAM_Slots = @($ramModules).Count | |
| RAM_SpeedMHz = ($ramModules | Select-Object -First 1).Speed | |
| RAM_Type = $ramType | |
| Disks_Physical = $physDisks -join " | " | |
| Disks_Logical = $logDisks -join " | " | |
| GPU = $gpuInfo -join " | " | |
| NICs = $nicInfo -join " || " | |
| } | |
| $row | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8 | |
| $cpuSummary = $cpu.Name.Trim() | |
| $ramSummary = $ramTotalGB.ToString() + " GB " + $ramType | |
| $diskSummary = $physDisks -join " | " | |
| $osSummary = $os.Caption + " (" + $os.BuildNumber + ")" | |
| Write-Host "" | |
| Write-Host " Archivo generado:" -ForegroundColor Green | |
| Write-Host " $OutputPath" -ForegroundColor Yellow | |
| Write-Host "" | |
| Write-Host " Resumen:" -ForegroundColor Cyan | |
| Write-Host " CPU: $cpuSummary" | |
| Write-Host " RAM: $ramSummary" | |
| Write-Host " Almacenamento: $diskSummary" | |
| Write-Host " S.O: $osSummary" | |
| Write-Host "" | |
| pause |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| :: ============================================================ | |
| :: wrapper.bat — Inventario de Hardware [Util] | |
| :: Requiere permisos de adminitracion. | |
| :: ============================================================ | |
| title Inventario de Hardware [Util] | |
| :: Evaluacion de permisos | |
| net session >nul 2>&1 | |
| if %errorLevel% neq 0 ( | |
| powershell -Command "Start-Process '%~f0' -Verb RunAs" | |
| exit /b | |
| ) | |
| :: Path para inventory.ps1 | |
| set "SCRIPT=%~dp0inventory.ps1" | |
| if not exist "%SCRIPT%" ( | |
| echo. | |
| echo ERROR: inventory.ps1 no ha sido encontrado para el launcher. | |
| echo Ambos archivos se deben encontrar en el mismo directorio. | |
| echo. | |
| pause | |
| exit /b 1 | |
| ) | |
| powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT%" | |
| exit /b 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment