powershell 列出Active Directory中使用的所有SPN

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 列出Active Directory中使用的所有SPN相关的知识,希望对你有一定的参考价值。

cls
$search = New-Object DirectoryServices.DirectorySearcher([ADSI]"")
$search.filter = "(servicePrincipalName=*)"

## You can use this to filter for OU's:
## $results = $search.Findall() | ?{ $_.path -like '*OU=whatever,DC=whatever,DC=whatever*' }
$results = $search.Findall()

foreach( $result in $results ) {
	$userEntry = $result.GetDirectoryEntry()
	Write-host "Object Name = " $userEntry.name -backgroundcolor "yellow" -foregroundcolor "black"
	Write-host "DN      =      "  $userEntry.distinguishedName
	Write-host "Object Cat. = "  $userEntry.objectCategory
	Write-host "servicePrincipalNames"

	$i=1
	foreach( $SPN in $userEntry.servicePrincipalName ) {
		Write-host "SPN(" $i ")   =      " $SPN
		$i+=1
	}
	Write-host ""
}

以上是关于powershell 列出Active Directory中使用的所有SPN的主要内容,如果未能解决你的问题,请参考以下文章

PowerShell Active Directory列出所有多值属性

powershell 用于将Active Directory组添加到Active Directory的Powershell脚本

powershell PowerShell:备份Active Directory#PowerShell#ActiveDirectory

powershell PowerShell:备份Active Directory组策略#PowerShell#ActiveDirecoty

powershell 使用powershell添加Active Directory组成员

powershell PowerShell:Active Directory中的操作系统计数