-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFFS_Connect.ps1
More file actions
175 lines (148 loc) · 10.9 KB
/
FFS_Connect.ps1
File metadata and controls
175 lines (148 loc) · 10.9 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
echo " _________________ __________ _ ___ ____________________"
echo " / ____/ ____/ ___/ / ____/ __ \/ | / / | / / ____/ ____/_ __/"
echo " / /_ / /_ \__ \ / / / / / / |/ / |/ / __/ / / / / "
echo " / __/ / __/ ___/ / / /___/ /_/ / /| / /| / /___/ /___ / / "
echo "/_/ /_/ /____/ \____/\____/_/ |_/_/ |_/_____/\____/ /_/ "
echo " "
echo "FFS Connect (This version from 2026-02-28)"
echo "Created by Fletcher Salesky"
#A PowerShell script that performs the most common fixes for Driver Station communication issues to the FIRST Robotics Competition Field Managment System Field Network.
#Learn more about this script, get updates, and contribute at https://driverstation.app
#Display current firewall settings.
Get-NetFirewallProfile | Format-List -Property Profile, Enabled
#DISABLE ALL WINDOWS FIREWALLS to allow communication to the FIRST Robotics Competition Field Managment System (FMS).
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
echo "Disabled Windows Firewall"
#Create Firewall allow rules for FIRST Robotics Competition Field Managment System (FMS) Ports (Ports from the Season Game Manual, FMS White Paper, WPIlib Docs and the FTAA/CSA Troubleshooting).
#Create Firewall allow rule for National Instruments mDNS Responser.
#Create Firewall allow rule for National Instruments Driver Station.
function Install-Firewall-Rules
{
echo "Checking if Firewall Rules already exist"
$rule = Get-NetFirewallRule -Group "Allow FRC Driver Station FMS Comms" 2> $null;
if ($rule) {
#enable-update rules if they exist.
echo "Existing rules found, Updated and Enabled Firewall Rules"
Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_TCP_in -Direction Inbound -Protocol TCP -RemoteAddress 10.0.0.0/8 -LocalPort 80,443,554,1110,1115,1120,1121,1122,1130,1140,1145,1150,1160,1164,1166,1180-1190,1250,1735,1740,1741,1742,1750,5353,5800-5810,6666,8080,8888 -Action Allow -Enabled True -Profile Any
Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_UDP_in -Direction Inbound -Protocol UDP -RemoteAddress 10.0.0.0/8 -LocalPort 80,443,554,1110,1115,1120,1121,1122,1130,1140,1145,1150,1160,1164,1166,1180-1190,1250,1735,1740,1741,1742,1750,5353,5800-5810,6666,8080,8888 -Action Allow -Enabled True -Profile Any
Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_mDNS_in -Direction Inbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsResponder.exe" -Action Allow -Enabled True -Profile Any
Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_TCP_out -Direction Outbound -Protocol TCP -RemoteAddress 10.0.0.0/8 -RemotePort 80,443,554,1110,1115,1120,1121,1122,1130,1140,1145,1150,1160,1164,1166,1180-1190,1250,1735,1740,1741,1742,1750,5353,5800-5810,6666,8080,8888 -Action Allow -Enabled True -Profile Any
Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_UDP_out -Direction Outbound -Protocol UDP -RemoteAddress 10.0.0.0/8 -RemotePort 80,443,554,1110,1115,1120,1121,1122,1130,1140,1145,1150,1160,1164,1166,1180-1190,1250,1735,1740,1741,1742,1750,5353,5800-5810,6666,8080,8888 -Action Allow -Enabled True -Profile Any
Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_mDNS_out -Direction Outbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsResponder.exe" -Action Allow -Enabled True -Profile Any
#check if DS software rules exists, enable-update rules if they exist
if (Get-NetFirewallRule "FRC_Driver_Station_FMS_Comms_DS_in" 2> $null)
{
Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_DS_in -Direction Inbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files (x86)\FRC Driver Station\DriverStation.exe" -Action Allow -Enabled True -Profile Any
Set-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_DS_out -Direction Outbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files (x86)\FRC Driver Station\DriverStation.exe" -Action Allow -Enabled True -Profile Any
}
#create DS software rules if they don't exist
else {
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_DS_in -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms NI Driver Stationr" -Direction Inbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files (x86)\FRC Driver Station\DriverStation.exe" -Action Allow -Profile Any
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_DS_out -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms NI Driver Station" -Direction Outbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files (x86)\FRC Driver Station\DriverStation.exe" -Action Allow -Profile Any
}
}
else {
#create rules if they do not exist.
echo "Rules do not exist, Creating Firewall Rules"
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_TCP_in -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms TCP" -Direction Inbound -Protocol TCP -RemoteAddress 10.0.0.0/8 -LocalPort 80,443,554,1110,1115,1120,1121,1122,1130,1140,1145,1150,1160,1164,1166,1180-1190,1250,1735,1740,1741,1742,1750,5353,5800-5810,6666,8080,8888 -Action Allow -Profile Any
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_UDP_in -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms UDP" -Direction Inbound -Protocol UDP -RemoteAddress 10.0.0.0/8 -LocalPort 80,443,554,1110,1115,1120,1121,1122,1130,1140,1145,1150,1160,1164,1166,1180-1190,1250,1735,1740,1741,1742,1750,5353,5800-5810,6666,8080,8888 -Action Allow -Profile Any
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_mDNS_in -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms NI mDNS Responder" -Direction Inbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsResponder.exe" -Action Allow -Profile Any
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_DS_in -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms NI Driver Stationr" -Direction Inbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files (x86)\FRC Driver Station\DriverStation.exe" -Action Allow -Profile Any
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_TCP_out -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms TCP" -Direction Outbound -Protocol TCP -RemoteAddress 10.0.0.0/8 -RemotePort 80,443,554,1110,1115,1120,1121,1122,1130,1140,1145,1150,1160,1164,1166,1180-1190,1250,1735,1740,1741,1742,1750,5353,5800-5810,6666,8080,8888 -Action Allow -Profile Any
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_UDP_out -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms UDP" -Direction Outbound -Protocol UDP -RemoteAddress 10.0.0.0/8 -RemotePort 80,443,554,1110,1115,1120,1121,1122,1130,1140,1145,1150,1160,1164,1166,1180-1190,1250,1735,1740,1741,1742,1750,5353,5800-5810,6666,8080,8888 -Action Allow -Profile Any
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_mDNS_out -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms NI mDNS Responder" -Direction Outbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsResponder.exe" -Action Allow -Profile Any
New-NetFirewallRule -Name FRC_Driver_Station_FMS_Comms_DS_out -Group "Allow FRC Driver Station FMS Comms" -DisplayName "FRC Driver Station FMS Comms NI Driver Station" -Direction Outbound -RemoteAddress 10.0.0.0/8 -Program "C:\Program Files (x86)\FRC Driver Station\DriverStation.exe" -Action Allow -Profile Any
}
}
#Enable the Firewall rules to allow communications to the FIRST Robotics Competition Field Managment System (FMS) field network.
Install-Firewall-Rules
echo "Firewall Opened to FRC Protocols"
#Display current firewall settings
Get-NetFirewallProfile | Format-List -Property Profile, Enabled
#Stop Windows updates Service to prevent updates during a FIRST Robotics Competition match.
net stop wuauserv
echo "Windows Update Service Stopped"
echo " "
echo " "
echo "Reset Ethernet adapters and disable other adapters?"
pause
#Get All Adapters
$adapters = Get-NetAdapter
#Disable and reset all adapters to resolve adapter issues
foreach ($adapter in $adapters)
{
Disable-NetAdapter -name $adapter.Name -Confirm:$false
}
#Get Physical Adapters
$physicalAdapters = Get-NetAdapter -Physical
#Enable Physical 802.3 Adapters and Disable IPv6 on Physical 802.3 Adapters becuase devices connect to the FIRST Robotics Competition Field Managment System (FMS) field network via ethernet using IPv4.
foreach ($adapter in $physicalAdapters)
{
if ($adapter.PhysicalMediaType -like "*802.3")
{
Enable-NetAdapter -name $adapter.Name -Confirm:$false
Disable-NetAdapterBinding -name $adapter.Name -ComponentID ms_tcpip6
}
}
echo "Wireless Adapters and IPv6 Disabled, Ethernet Adapters Reset"
#Show Status of Adapters
Get-NetAdapter | Format-List -Property Name,Status,AdminStatus,HardwareInterface
echo "Set Ethernet adapters to use DHCP?"
pause
#Set Physical 802.3 Adapters to use DHCP
foreach ($adapter in $physicalAdapters)
{
if ($adapter.PhysicalMediaType -like "*802.3")
{
netsh interface ip set address $adapter.Name dhcp
netsh interface ip set dns $adapter.Name dhcp
}
}
#Get All IPv4 Address
$IPAddresses = Get-NetIPAddress -AddressFamily IPv4
#Remove Static IPv4 addresses on Physical Adapters
foreach ($IPAddress in $IPAddresses)
{
if (($IPAddress.SuffixOrigin -like "*Manual") -and ($IPAddress.InterfaceAlias -eq $adapter.Name))
{
Remove-NetIPAddress -IPAddress $IPAddress.IPv4Address
}
}
echo "Ethernet Adapters set to use DHCP"
#Flush DNS
Clear-DnsClientCache
echo "DNS Cache Flushed"
#Release all DCHP leases
ipconfig /release
ipconfig /release6
echo "All DHCP Leases Released"
#Ask to open Network Adapters Control Panel to allow Static IP setting instead of using DHCP
$confirmation = Read-Host "Open Network Adapters Control Panel to set Static IP? [Y/N]"
while($confirmation -ne "n")
{
if ($confirmation -eq 'y')
{
control ncpa.cpl
echo "Opened ncpa.cpl"
echo ""
echo ""
Start-Sleep -s 2
exit
}
$confirmation = Read-Host "Open Network Adapters Control Panel to set Static IP? Must Answer [Y or N]"
}
echo "Getting IP Address with DHCP"
#Renew DHCP for Physical 802.3 Adapters
foreach ($adapter in $physicalAdapters)
{
if ($adapter.PhysicalMediaType -like "*802.3")
{
ipconfig /renew $adapter.Name
}
}
Echo "Ethernet Adapter DHCP Lease Renewed"
Start-Sleep -s 2
#Set Connection to Private
echo "Set Network Category as Private"
Set-NetConnectionProfile -NetworkCategory "Private"
Start-Sleep -s 2