forked from MrAnde7son/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-WriteSPNUsers.ps1
44 lines (35 loc) · 1.11 KB
/
Get-WriteSPNUsers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<#
Author: Itamar Mizrahi (@MrAnde7son)
License: GNU v3
Required Dependencies: None
Optional Dependencies: None
#>
function Get-WriteSPNUsers
{
<#
.SYNOPSIS
Searches and prints users with "Write servicePrincipalName" right.
Author: Itamar Mizrahi (@MrAnde7son)
License: GNU v3
Required Dependencies: None
Optional Dependencies: None
.DESCRIPTION
.PARAMETER Domain
Domain to search, default is current user's domain.
.EXAMPLE
#>
[CmdletBinding()]
param
(
[parameter(Mandatory=$False, Position=0, ValueFromPipeline=$True)]
[string]$Domain = $env:USERDOMAIN
)
$writeSPNUsers = @()
$users = Get-ADUser -Filter * -Server $DOMAIN | select distinguishedname
foreach ($user in $users)
{
$userAD = "AD:\" + $user.distinguishedname
$writeSPNUsers += ((Get-Acl $userAD).access | ?{$_.ObjectType -eq "f3a64788-5306-11d1-a9c5-0000f80367c1"} | select IdentityReference).IdentityReference.value
Write-Host $user.distinguishedname
}
}