-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidation.ps1
52 lines (43 loc) · 1.6 KB
/
validation.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
# Run PowerShell as an administrator and execute the following command
Write-Host "Validating the network connectivity to the domain controller..."
Add-WindowsFeature RSAT-AD-PowerShell | Out-Null
# Import the Active Directory module
Import-Module ActiveDirectory
# Get the domain controller
$DomainController = Get-ADDomainController
# Write the name of the domain controller being used by the pod
Write-Host "Domain Controller: $($DomainController.HostName)"
# Define the target host and ports
$targetHost = $DomainController.HostName
$targetTcpPorts = 53, 88, 139, 389, 636
# Loop through each port
foreach ($targetPort in $targetTcpPorts) {
# Test the connection
$connectionTest = Test-NetConnection -ComputerName $targetHost -Port $targetPort
# Check if the port is open
if ($connectionTest.TcpTestSucceeded) {
Write-Output "TCP port $targetPort is open on $targetHost."
} else {
Write-Output "TCP port $targetPort is not open on $targetHost."
}
}
# Define the target host and ports
$targetHost = $DomainController.HostName
$targetUdpPorts = 53, 88, 389
# Loop through each port
foreach ($targetPort in $targetUdpPorts) {
# Test UDP connection
try {
$udpClient = New-Object System.Net.Sockets.UdpClient($targetHost, $targetPort)
Write-Output "UDP port $targetPort is open on $targetHost."
} catch {
Write-Output "UDP port $targetPort is not open on $targetHost."
} finally {
if ($udpClient) {
$udpClient.Close()
}
}
}
# Shows kerberos ticket information
Write-Host "Kerberos ticket information:"
klist get krbtgt