top of page

PowerShell - List All Domain SPNs

  • Writer: Jon Boyette
    Jon Boyette
  • Oct 12, 2022
  • 1 min read

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related

#Build LDAP filters to look for users with SPN values registered for current domain

$ldapFilter = "(&(objectclass=user)(objectcategory=user)(servicePrincipalName=*))"

$domain = New-Object System.DirectoryServices.DirectoryEntry

$search = New-Object System.DirectoryServices.DirectorySearcher

$search.SearchRoot = $domain

$search.PageSize = 1000

$search.Filter = $ldapFilter

$search.SearchScope = "Subtree"

#Execute Search

$results = $search.FindAll()

#Display SPN values from the returned objects

foreach ($result in $results)

{

$userEntry = $result.GetDirectoryEntry()

Write-Host "User Name = " $userEntry.name

foreach ($SPN in $userEntry.servicePrincipalName)

{

Write-Host "SPN = " $SPN

}

Write-Host ""

}


 
 
 

Recent Posts

See All
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 
PowerShell - Get-ADUser

Get ADUser, OU, Name, Username, and direct Manager, save as whatever name.ps1 suits you, make this 2 lines below, first stops at "second"...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page