Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue of 801 #875

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Vagrant/scripts/fix-failed-to-join-domain_interface-issue.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# explanation of script>
# 1. get list of all IP's on VM
# 2. find interface with ip in correct subnet. I.e. same range as DNS=192.168.56.102
# 3. Change the interfaceMetric of this interface to have higher priority than the others

# Step 1
$ips=Get-NetIPAddress

# Step 2
# Two variables used in while-loop.
$correctInterfaceIndex=''
[bool]$correctInterface # Cast variable to boolean. Used in while loop
$i=0

# While loop> run until correct interface is found
while ($i -le $ips.Length -and !$correctInterfaceIndex ) {
#$ips[$i].IPAddress
if ($ips[$i].IPAddress -like "*192.168.*"){
$correctInterfaceIndex=$ips[$i].InterfaceIndex
#$correctInterfaceIndex
}
$i++
}

#Step 3
#Get current InterfaceMetric of NetworkInterface with index $correntInterfaceIndex
$current_interface_metric=$(Get-NetIPInterface -InterfaceIndex $correctInterfaceIndex).InterfaceMetric
$current_interface_metric

# Set interfaceMetric with higher priority
Set-NetIPInterface -InterfaceIndex $correctInterfaceIndex -InterfaceMetric $($current_interface_metric-1)
$(Get-NetIPInterface -InterfaceIndex $correctInterfaceIndex).InterfaceMetric
1 change: 1 addition & 0 deletions Vagrant/scripts/join-domain.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ If (($hostname -eq "wef") -or ($hostname -eq "exchange")) {
While ($tries -lt 3) {
Try {
$tries += 1
. c:\vagrant\scripts\fix-failed-to-join-domain_interface-issue.ps1
Write-Host "$('[{0:HH:mm}]' -f (Get-Date)) Try # $tries"
Add-Computer -DomainName "windomain.local" -credential $DomainCred -OUPath "ou=Workstations,dc=windomain,dc=local"
Break
Expand Down