Skip to content

Instantly share code, notes, and snippets.

@nesh
Created February 15, 2021 12:27
Show Gist options
  • Save nesh/e80983dd23f68db74f061481ecd397b7 to your computer and use it in GitHub Desktop.
Save nesh/e80983dd23f68db74f061481ecd397b7 to your computer and use it in GitHub Desktop.
Destiny 2 enable/disable firewall for solo strikes
<# This code requests administrator permissions so that the script can modify your Windows Firewall rules as needed #>
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
<# Once user input is detected, the script resumes and removes the port blocks, restoring things to how they were prior to running #>
Remove-NetFirewallRule -DisplayName "Destiny2-Solo-1"
Remove-NetFirewallRule -DisplayName "Destiny2-Solo-2"
Remove-NetFirewallRule -DisplayName "Destiny2-Solo-3"
Remove-NetFirewallRule -DisplayName "Destiny2-Solo-4"
<# This code requests administrator permissions so that the script can modify your Windows Firewall rules as needed #>
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
<# These four commands create sets of blocked ports, both inbound and outbound #>
New-NetFirewallRule -DisplayName "Destiny2-Solo-1" -Direction Outbound -RemotePort 27000-27200,3097 -Protocol TCP -Action Block
New-NetFirewallRule -DisplayName "Destiny2-Solo-2" -Direction Outbound -RemotePort 27000-27200,3097 -Protocol UDP -Action Block
New-NetFirewallRule -DisplayName "Destiny2-Solo-3" -Direction Inbound -RemotePort 27000-27200,3097 -Protocol TCP -Action Block
New-NetFirewallRule -DisplayName "Destiny2-Solo-4" -Direction Inbound -RemotePort 27000-27200,3097 -Protocol UDP -Action Block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment