1

I need to come up with PowerShell code that puts a firewall rule in place, where this rule is tied to an executable that, in its turn, comes from an installed AppX package. The executable, thus, sits beneath C:\Program Files\WindowsApps.

Firewall rules can be tied to executables but is this the right approach in the case of an executable sitting beneath C:\Program Files\WindowsApps in the first place?

Altus
  • 23
  • 4

1 Answers1

0

This can be done!

  1. Open an elevated powershell window
  2. Run the command Get-AppxPackage -AllUsers and find the name of the package you want (ie - Microsoft.WindowsCalculator_10.0.22000.0_x64__8wekyb3d8bbwe)
  3. Open the directory and find the executable file in there, and make a note of the full path
  4. Create a new firewall rule with powershell:
    a. New-NetFirewallRule -DisplayName "Allow Inbound Port 80 for Windows Calculator" -Direction Inbound -LocalPort 80 -Program "C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.0.22000.0_x64__8wekyb3d8bbwe\calculator.exe" -Action Allow
danijeljw-RPC
  • 345
  • 2
  • 13
  • Thanks, so it's the right approach to refer to the AppX executable just like to any other executable? – Altus Apr 24 '23 at 06:30