miércoles, 25 de junio de 2025

WINDOWS. PS. SECURITY. SPN. Service Principal Name

Purpose

PowerShell script that will allow you to verify if a SPN (Service Principal Name) exists in the domain that allows you to generate a TGS (Ticket Granting Service) ticket. This script searches Active Directory for registered SPNs and displays those that meet the criteria.

Steps

# Importar el módulo de Active Directory

Import-Module ActiveDirectory

# Definir el SPN que deseas buscar

$spn = "HTTP/*"

# Buscar cuentas de servicio con el SPN especificado

$cuentasConSPN = Get-ADObject -Filter {ServicePrincipalName -like $spn} -Properties ServicePrincipalName, Name

# Verificar si se encontraron cuentas con el SPN

if ($cuentasConSPN) {

    Write-Output "Se encontraron las siguientes cuentas con el SPN '$spn':"

    $cuentasConSPN | Select-Object Name, ServicePrincipalName | Format-Table -AutoSize

} else {

    Write-Output "No se encontraron cuentas con el SPN '$spn'."

}



By GoN | Published: Jun 2025 | Last Updated:

No hay comentarios: