Skip to content

Commit 4870199

Browse files
committed
Create PowerShell version
Created PowerShell version of the Script with improved features and efficiency
1 parent 6b57e31 commit 4870199

File tree

4 files changed

+187
-0
lines changed

4 files changed

+187
-0
lines changed

FFS_Connect.ps1

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Created by Fletcher Salesky
2+
# FFS Connect (This verson from 2021-10-06)
3+
4+
#Display current firewall settings
5+
Get-NetFirewallProfile | Format-List -Property Profile, Enabled
6+
7+
#DISABLE ALL WINDOWS FIREWALLS
8+
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
9+
echo "Disabled Windows Firewall"
10+
11+
#Create Firewall allow rules for FRC FMS Ports (Ports from FMS White Paper, WPIlib and The FTAA/CSA Troubleshooting)
12+
#Create Firwall allow rule for NI mDNS Responser
13+
function Install-Firewall-Rules
14+
{
15+
$rule = Get-NetFirewallRule -Group "Allow FRC Driver Station FMS Comms" 2> $null;
16+
if ($rule) {
17+
#enable-update rules if they exist
18+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled True -Profile Any
19+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled True -Profile Any
20+
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
21+
22+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled True -Profile Any
23+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled True -Profile Any
24+
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
25+
}
26+
27+
else {
28+
#create rules if they do not exist
29+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow
30+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow
31+
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
32+
33+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow
34+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow
35+
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
36+
}
37+
}
38+
39+
#Enable the Firewall rules to allow comms to the field network
40+
Install-Firewall-Rules
41+
echo "Firewall Opened to FRC Protocols"
42+
43+
#Display current firewall settings
44+
Get-NetFirewallProfile | Format-List -Property Profile, Enabled
45+
46+
#Stop Windows updates
47+
net stop wuauserv
48+
echo "Windows Update Service Stopped"
49+
echo ""
50+
echo "Reset Ethernet adapters and disable other adapters?"
51+
pause
52+
53+
#Get All Adapters
54+
$adapters = Get-NetAdapter
55+
56+
#Disable all adapters
57+
foreach ($adapter in $adapters)
58+
{
59+
Disable-NetAdapter -name $adapter.Name -Confirm:$false
60+
}
61+
62+
#Get Physical Adapters
63+
$physicalAdapters = Get-NetAdapter -Physical
64+
65+
#Enable Physical 802.3 Adapters and Disable IPv6 on Physical 802.3 Adapters
66+
foreach ($adapter in $physicalAdapters)
67+
{
68+
if ($adapter.PhysicalMediaType -like "*802.3")
69+
{
70+
Enable-NetAdapter -name $adapter.Name -Confirm:$false
71+
Disable-NetAdapterBinding -name $adapter.Name -ComponentID ms_tcpip6
72+
}
73+
74+
}
75+
echo "Wireless Adapters Disabled, Ethernet Adapters Reset"
76+
#Show Status of Adapters
77+
Get-NetAdapter | Format-List -Property Name,Status,AdminStatus,HardwareInterface
78+
79+
echo "Set Ethernet adapters to use DHCP?"
80+
pause
81+
82+
#Set Physical 802.3 Adapters to use DHCP
83+
foreach ($adapter in $physicalAdapters)
84+
{
85+
if ($adapter.PhysicalMediaType -like "*802.3")
86+
{
87+
netsh interface ip set address $adapter.Name dhcp
88+
netsh interface ip set dns $adapter.Name dhcp
89+
}
90+
91+
}
92+
93+
#flush DNS
94+
Clear-DnsClientCache
95+
echo "DNS Flushed"
96+
#Release everything
97+
ipconfig /release
98+
ipconfig /release6
99+
echo "IP Addresses Released"
100+
101+
#open Network Adapters Conntrol Panel to allow Static IP setting
102+
control ncpa.cpl
103+
104+
echo "Get IP Address with DHCP?"
105+
pause
106+
107+
#Renew DHCP for Physical 802.3 Adapters
108+
foreach ($adapter in $physicalAdapters)
109+
{
110+
if ($adapter.PhysicalMediaType -like "*802.3")
111+
{
112+
ipconfig /renew $adapter.Name
113+
}
114+
115+
}
116+
Echo "Ethernet Adapter IP Addresses Renewed"
117+

Launch_FFS_ConnectPS.bat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo off
2+
rem Created by Fletcher Salesky
3+
rem FFS Connect Powershell Launcher (This verson from 2021-10-06)
4+
5+
Title FFS Connect to The Field
6+
rem fancy color
7+
color 06
8+
cls
9+
rem Launch Powershell Script
10+
if exist "%~dp0FFS_Connect.ps1" (Powershell -noprofile -executionpolicy bypass -file %~dp0FFS_Connect.ps1)
11+
pause
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo off
2+
rem Created by Fletcher Salesky
3+
rem Revert FFS Connect Changes Powershell Launcher (This verson from 2021-10-06)
4+
5+
Title Revert FFS Connect Changes
6+
rem fancy color
7+
color 06
8+
cls
9+
rem Launch Powershell Script
10+
if exist "%~dp0Revert_FFS_Connect_Changes.ps1" (Powershell -noprofile -executionpolicy bypass -file %~dp0Revert_FFS_Connect_Changes.ps1)
11+
pause

Revert_FFS_Connect_Changes.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Created by Fletcher Salesky
2+
# This Script undoes the changes made by FFS Connect (This verson from 2021-10-06)
3+
4+
#Display current firewall settings
5+
Get-NetFirewallProfile | Format-List -Property Profile, Enabled
6+
7+
#Enable ALL WINDOWS FIREWALLS
8+
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
9+
echo "Enabled Windows Firewall"
10+
11+
#Disable Field Netowrk comms rules
12+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled False -Profile Any
13+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled False -Profile Any
14+
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 False -Profile Any
15+
16+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled False -Profile Any
17+
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,1130,1140,1150,1160,1180-1190,1250,1735,1740,1750,5353,5800-5810,8080,8888 -Action Allow -Enabled False -Profile Any
18+
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 False -Profile Any
19+
20+
#Display current firewall settings
21+
Get-NetFirewallProfile | Format-List -Property Profile, Enabled
22+
23+
#Start Windows updates
24+
Set-Service -Name wuauserv -Status Running
25+
echo "Windows Update Service Started"
26+
27+
#Get Adapters
28+
$adapters = Get-NetAdapter
29+
30+
#Enable all adapters
31+
foreach ($adapter in $adapters)
32+
{
33+
Enable-NetAdapter -name $adapter.Name -Confirm:$false
34+
}
35+
36+
#Enable IPv6 on 802.3 Adapters
37+
foreach ($adapter in $adapters)
38+
{
39+
if ($adapter.PhysicalMediaType -like "*802.3")
40+
{
41+
Disable-NetAdapterBinding -name $adapter.Name -ComponentID ms_tcpip6
42+
}
43+
44+
}
45+
echo "Adapters Enabled, IPv6 Enabled"
46+
#Show Status of Adapters
47+
Get-NetAdapter | Format-List -Property Name,Status,AdminStatus
48+

0 commit comments

Comments
 (0)