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?
This can be done!
Get-AppxPackage -AllUsersand find the name of the package you want (ie - Microsoft.WindowsCalculator_10.0.22000.0_x64__8wekyb3d8bbwe)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