
Serie · Auditoría e Inventario de Infraestructura · Guía 3 de 10
Los roles y las características definen para qué sirve un servidor y cuánta superficie de ataque tiene. Cada componente instalado es código que hay que parchear, y los que nadie usa son riesgo sin beneficio.
Esta guía usa Get-WindowsFeature para ver qué hay instalado, primero en un servidor y después en todos. Es una auditoría: no se instala ni se quita nada. Parte de la variable $servidores de la guía 2.
Los nombres, direcciones IP, versiones y números de serie de las pantallas son de ejemplo: en tu servidor serán distintos.
Listar lo instalado en un servidor
Abre PowerShell como administrador en el servidor que quieres revisar. Get-WindowsFeature existe solo en Windows Server y lista todos los componentes; el filtro deja los instalados.
Get-WindowsFeature | Where-Object Installed | Select-Object Name,FeatureType,InstallState
PS C:\Auditoria> Get-WindowsFeature | Where-Object Installed | Select-Object Name,FeatureType,InstallState Name FeatureType InstallState---- ----------- ------------FileAndStorage-Services Role InstalledFile-Services Role Service InstalledFS-FileServer Role Service InstalledFS-SMB1 Feature InstalledStorage-Services Role Service InstalledNET-Framework-45-Features Feature InstalledNET-Framework-45-Core Feature InstalledNET-WCF-Services45 Feature InstalledWindows-Defender Feature InstalledTelnet-Client Feature Installed PS C:\Auditoria>
FS-SMB1 y Telnet-Client.Distinguir roles, servicios de rol y características
La columna FeatureType tiene tres valores: Role es lo que hace el servidor, Role Service es una parte de un rol y Feature es una función adicional. Para saber a qué se dedica un servidor, mira primero los roles.
Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq 'Role' } | Select-Object Name,DisplayName,FeatureTypePS C:\Auditoria> Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq 'Role' } | Select-Object Name,DisplayName,FeatureType Name DisplayName FeatureType---- ----------- -----------AD-Domain-Services Active Directory Domain Services RoleDNS DNS Server RoleFileAndStorage-Services File and Storage Services Role PS C:\Auditoria>
FileAndStorage-Services viene instalado en casi todos los servidores. No lo cuentes como un rol que alguien eligió.Revisar los roles de todos los servidores
Con Invoke-Command la misma consulta corre en los cinco servidores. El filtro quita FileAndStorage-Services para que se vean solo los roles elegidos.
Invoke-Command -ComputerName $servidores -ScriptBlock {
Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq 'Role' -and $_.Name -ne 'FileAndStorage-Services' } | Select-Object Name,DisplayName
} | Select-Object PSComputerName,Name,DisplayName | Sort-Object PSComputerName | Format-Table -AutoSizePS C:\Auditoria> Invoke-Command -ComputerName $servidores -ScriptBlock { ... } | Select-Object PSComputerName,Name,DisplayName | Sort-Object PSComputerName | Format-Table -AutoSize PSComputerName Name DisplayName-------------- ---- -----------SRV-APP01 Web-Server Web Server (IIS)SRV-DC01 AD-Domain-Services Active Directory Domain ServicesSRV-DC01 DNS DNS ServerSRV-DC02 AD-Domain-Services Active Directory Domain ServicesSRV-DC02 DNS DNS Server PS C:\Auditoria>
Buscar características de riesgo
Algunas características son herencia de versiones antiguas: SMB 1.0, Telnet, TFTP, el motor de PowerShell 2.0 y el servidor FTP. Casi nunca se necesitan y todas amplían la superficie de ataque.
Invoke-Command -ComputerName $servidores -ScriptBlock {
Get-WindowsFeature -Name FS-SMB1,Telnet-Client,TFTP-Client,PowerShell-V2,Web-Ftp-Server | Where-Object Installed | Select-Object Name,DisplayName,InstallState
} | Select-Object PSComputerName,Name,DisplayName,InstallState | Sort-Object PSComputerName | Format-Table -AutoSizePS C:\Auditoria> Invoke-Command -ComputerName $servidores -ScriptBlock { ... } | Select-Object PSComputerName,Name,DisplayName,InstallState | Sort-Object PSComputerName | Format-Table -AutoSize PSComputerName Name DisplayName InstallState-------------- ---- ----------- ------------SRV-APP01 Web-Ftp-Server FTP Server InstalledSRV-FS01 FS-SMB1 SMB 1.0/CIFS File Sharing Support InstalledSRV-FS01 Telnet-Client Telnet Client InstalledSRV-SQL01 Telnet-Client Telnet Client Installed PS C:\Auditoria>
Guardar el inventario de roles y características
Exporta todo lo instalado de todos los servidores a un CSV y cuenta cuántos componentes tiene cada uno.
Invoke-Command -ComputerName $servidores -ScriptBlock { Get-WindowsFeature | Where-Object Installed | Select-Object Name,DisplayName,FeatureType } | Select-Object PSComputerName,Name,DisplayName,FeatureType | Export-Csv C:\Auditoria\roles-caracteristicas.csv -NoTypeInformation -Encoding UTF8Import-Csv C:\Auditoria\roles-caracteristicas.csv | Group-Object PSComputerName | Select-Object Name,Count
PS C:\Auditoria> Invoke-Command -ComputerName $servidores -ScriptBlock { Get-WindowsFeature | Where-Object Installed | Select-Object Name,DisplayName,FeatureType } | Select-Object PSComputerName,Name,DisplayName,FeatureType | Export-Csv C:\Auditoria\roles-caracteristicas.csv -NoTypeInformation -Encoding UTF8PS C:\Auditoria> Import-Csv C:\Auditoria\roles-caracteristicas.csv | Group-Object PSComputerName | Select-Object Name,Count Name Count---- -----SRV-APP01 41SRV-DC01 27SRV-DC02 27SRV-FS01 24SRV-SQL01 18 PS C:\Auditoria>
Todos los comandos
La secuencia completa, para copiarla de una vez. Pégala en una consola de PowerShell abierta como administrador.
Get-WindowsFeature | Where-Object Installed | Select-Object Name,FeatureType,InstallState
Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq 'Role' } | Select-Object Name,DisplayName,FeatureType
Invoke-Command -ComputerName $servidores -ScriptBlock {
Get-WindowsFeature | Where-Object { $_.Installed -and $_.FeatureType -eq 'Role' -and $_.Name -ne 'FileAndStorage-Services' } | Select-Object Name,DisplayName
} | Select-Object PSComputerName,Name,DisplayName | Sort-Object PSComputerName | Format-Table -AutoSize
Invoke-Command -ComputerName $servidores -ScriptBlock {
Get-WindowsFeature -Name FS-SMB1,Telnet-Client,TFTP-Client,PowerShell-V2,Web-Ftp-Server | Where-Object Installed | Select-Object Name,DisplayName,InstallState
} | Select-Object PSComputerName,Name,DisplayName,InstallState | Sort-Object PSComputerName | Format-Table -AutoSize
Invoke-Command -ComputerName $servidores -ScriptBlock { Get-WindowsFeature | Where-Object Installed | Select-Object Name,DisplayName,FeatureType } | Select-Object PSComputerName,Name,DisplayName,FeatureType | Export-Csv C:\Auditoria\roles-caracteristicas.csv -NoTypeInformation -Encoding UTF8
Import-Csv C:\Auditoria\roles-caracteristicas.csv | Group-Object PSComputerName | Select-Object Name,CountEn la guía 4 pasamos al hardware: procesador, memoria y almacenamiento de cada servidor. Guarda roles-caracteristicas.csv junto al resto de archivos de C:\Auditoria.
Ver las 10 guías de la serie
- Identificación de servidores Windows Server 2022 y 2025
- Registro de hostname, IP, versión, build y número de serie
- Identificación de roles y características instaladas
- Inventario de hardware, CPU, memoria y almacenamiento
- Identificación de servicios, procesos y aplicaciones instaladas
- Identificación de puertos TCP y UDP en escucha
- Identificación de conexiones de red activas y establecidas
- Detección de software obsoleto, vulnerable o sin soporte
- Identificación de cuentas locales, grupos y administradores
- Informe inicial de exposición y riesgos