-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDetectDuplicateIpAddr.ps1
More file actions
55 lines (38 loc) · 1.53 KB
/
DetectDuplicateIpAddr.ps1
File metadata and controls
55 lines (38 loc) · 1.53 KB
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
Write-Host "Detecting duplicate IP addresses on the node..."
$BaseDir = "c:\k\debug"
Write-Host "Trying to load HNS module..."
ipmo $BaseDir\hns.v2.psm1 -Force | Write-Host
$iter = 1
pktmon stop # Stopping if pktmon is already running
# Start pktmon
Write-Host "Starting pktmon with trace level 6 for HNS"
pktmon start --trace -p Microsoft-Windows-Host-Network-Service -l 6 -f traces.etl -s 2048
while($true){
$ipAddresses = ((Get-HnsEndpoint).IpConfigurations).IpAddress
Write-Host "Checking for duplicate IP addresses inside the loop..."
$duplicateIpAddr = $ipAddresses | Group-Object | Where-Object { $_.Count -gt 1 }
if($duplicateIpAddr.Count -gt 0){
break
}
$iter++
Start-Sleep -Seconds 60
}
Write-Host "Duplicate IP addresses found on the node, Duplicate IP addresses are:"
foreach($ipGroup in $duplicateIpAddr){
Write-Host $ipGroup.Name
}
Write-Host "Stopping pktmon..."
# Stop pktmon
pktmon stop
Write-Host "Collecting Windows logs..."
$collectWindowsLogs = "$BaseDir\collect-windows-logs.ps1"
powershell $collectWindowsLogs | Write-Host
Write-Host "Collected Windows logs and trace are at $PWD"
while($true){
if ($iter -Eq 1) {
Write-Host "The issue was detected in the first iteration and it may have happened already, and log rotation may have occurred."
} else {
Write-Host "Issue detected. Please download and review the collected Windows logs and also traces from the following path: $PWD\traces.etl"
}
Start-Sleep -Seconds 3600
}