cancel
Showing results for 
Search instead for 
Did you mean: 

Powershell to push Windows firewall rules

paul-mb
Novitiate II

I've started at a new company recently who use JumpCloud, so I'm also extremely new to JumpCloud.

Our staff are using a new app which needs to get through the Windows 10 firewall. I've written a powershell script that works perfectly on my PC.

I've added it as a Command under Device Management, uploaded the approprirate CSV, created a group and bound a couple of laptops to it.

It executes on my laptop with no issue, when I run the cmd from the portal my laptop received the updated firewall rules within a couple of minutes. For another test user it does not deploy. I'm assuming this may be because I have admin rights on my laptop, but I also assumed the JumpCloud Agent would run the script locally with admin rights?

Any advice would be appreciated!

The script:

Set-ExecutionPolicy Unrestricted -force
Install-Module -Name Firewall-Manager
Import-Module Firewall-Manager
Remove-NetFirewallRule -DisplayName "app.exe"
Import-FirewallRules "C:\Windows\Temp\appfw.csv"

1 ACCEPTED SOLUTION

Figured it out. Checking the Results tab of the Command section I could see that the script was failing with error:

"user declined to install module Firewall-Manager".

Added the -force switch to a couple of lines of code, and it now runs without any issues:

Set-ExecutionPolicy Unrestricted -force
Install-Module -Name Firewall-Manager -force
Import-Module Firewall-Manager -force
Remove-NetFirewallRule -DisplayName "app.exe"
Import-FirewallRules "C:\Windows\Temp\appfw.csv"

 

View solution in original post

3 REPLIES 3

JCDavid
Iron II
Iron II

Hello @paul-mb ,

JumpCloud has a very granular policy for Windows Firewall (local). Would it be helpful to use the pre-built policy?

Screenshot 2022-07-15 at 10.54.34 AM.png

I'm flagging this with a colleague to address your PowerShell question.

 

-d

Hi JC, 

Thanks for replying. As I'm so new to JumpCloud I'm not sure if this will work. I'm not sure if my powershell solution is best practice or not though! Happy to be advised otherwise.

I just need to add an exception for one application (a softphone app) which is hosted in the C:\users\%userprofile%\appdata\Remote\ folder

 

Cheers,

Paul

Figured it out. Checking the Results tab of the Command section I could see that the script was failing with error:

"user declined to install module Firewall-Manager".

Added the -force switch to a couple of lines of code, and it now runs without any issues:

Set-ExecutionPolicy Unrestricted -force
Install-Module -Name Firewall-Manager -force
Import-Module Firewall-Manager -force
Remove-NetFirewallRule -DisplayName "app.exe"
Import-FirewallRules "C:\Windows\Temp\appfw.csv"