-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathTest-LDAPS.ps1
100 lines (67 loc) · 2.37 KB
/
Test-LDAPS.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<#
.SYNOPSIS
This cmdlet is used to verify your domain controller is correctly configured to accept LDAP over SSL connections
.PARAMETER ComputerName
Specifies one computer name or a comma-separated array of computer names. This cmdlet accepts
ComputerName objects from the pipeline or variables.
Type the NetBIOS name, an IP address, or a fully qualified domain name of a remote computer. To specify the
local computer, type the computer name, a dot `.`, or localhost.
This parameter doesn't rely on PowerShell remoting. You can use the ComputerName parameter even if your
computer isn't configured to run remote commands.
.NOTES
Author: Robert H. Osborne
Alias: tobor
Contact: [email protected]
.LINK
https://osbornepro.com
https://writeups.osbornepro.com
https://btpssecpack.osbornepro.com
https://github.com/tobor88
https://gitlab.com/tobor88
https://www.powershellgallery.com/profiles/tobor
https://www.linkedin.com/in/roberthosborne/
https://www.credly.com/users/roberthosborne/badges
https://www.hackthebox.eu/profile/52286
.INPUTS
System.String
Accepts computer names from the pipeline or variables. (Domain Controllers are of course required)
.OUTPUTS
PSCustomObject
#>
Function Test-LDAPS {
[CmdletBinding()]
param (
[Parameter(
Mandatory=$True,
ValueFromPipeLine=$True,
ValueFromPipeLineByPropertyName=$True,
HelpMessage='Enter the hostname or ip address of a domain controller to test LDAPS on. Separate multiple values with a comma')]
[Alias('cn','Computer','Server')]
[String[]]$ComputerName
) # End param
BEGIN {
$Obj = @()
} # End BEGIN
PROCESS {
ForEach ($Computadora in $ComputerName) {
Try {
Write-Verbose "[*] Attempting to connect to port 636 on $Computadora"
$LDAPS = [ADSI]("LDAP://" + $Computadora + ":636")
} # End Try
Catch {
Write-Verbose "[x] Trouble connecting to $Computadora on port 636"
$Error[0]
} # End Catch
If ($LDAPS.Path) {
$Protocol = 'LDAPS'
} # End If
Else {
$Protocol = 'x'
} # End Else
$Obj += New-Object -TypeName PSObject -Property @{Server="$Computadora";Protocol="$Protocol"}
} # End ForEach
} # End PROCESS
END {
$Obj
} # End END
} # End Test-LDAPS