Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

Group Policy

Hello There,

I am needing to setup Group Policy to enable my laptop users to have windows firewall  enabled when they are NOT on the domain (only). I understand that I could probably do this from local computer policy but as I understand this takes precedence over the policy set in AD and we need Windows Firewall disabled when users are on the domain. Can this be done?

Thanks

0
JAKJO
Asked:
JAKJO
  • 5
  • 5
  • 2
1 Solution
 
Brum07Commented:
I would put the users in a group and create a policy that had a VBScript logon to turn the firewall off;

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
objPolicy.FirewallEnabled = FALSE

Then a log off VBScript to enable the firewall;

Set firewall = CreateObject("HNetCfg.FwMgr")
Set firewallPolicy = firewall.LocalPolicy.CurrentProfile
firewallPolicy.FirewallEnabled = TRUE

Regards
0
 
knightfoxCommented:
Hi,

You are correct GPOs are processed  in order.. Global, Domain, Local which means that the local policy is always the last to apply.

you could however do this using logon and logoff scripts on your domain

Disable the firewall:

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

objPolicy.FirewallEnabled = FALSE

Enable the Firewall:

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

objPolicy.FirewallEnabled = TRUE

Save them as VBS and set the disable as startup and enable as shutdown...

/Fox
0
 
JAKJOAuthor Commented:
Probably a really stupid question Fox but how do I save as vbs??
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Brum07Commented:
Open text file, enter the code and save as starytp.vbs making sure file type is all files.

Regards
0
 
knightfoxCommented:
you made need to unhide file extentions in explorer...

right click start > Explore > 

Tools > Folder Options > View  - remove the tick in "Hide extentions for known file types"

Then as Brum says, open notepad and save the files as .vbs

/Fox
0
 
JAKJOAuthor Commented:
Thanks, but the scripts do not appear to working when I log onto the domain the firewall is enabled. Also when I do, which is good. I need to disable it when users to logon to the domain and enable when they don't.

Thanks in advance
0
 
knightfoxCommented:
ok...

I think I know where you went wrong.. create a script called "enable firewall.vbs"

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

objPolicy.FirewallEnabled = TRUE

Create another script called "disable Firewall.vbs"

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

objPolicy.FirewallEnabled = FALSE

Place both scripts in %windows%\SYSVOL\DOMAIN\Scripts folder....

Open the group policy that you are using to apply logon scripts to nework users...

Under the computer configuration > windows settings > Scripts (Startup/Shutdown)

Select startup > Add and browse the following  \\domainname.xxx\sysvol\scripts\disable firewall.vbs

click ok

Select shutdown Add and browse the following  \\domainname.xxx\sysvol\scripts\enable firewall.vbs

now ensure that the GPO is applied to Authenticated users.

now reboot the station and you should see the startup scripts process... logon and the firewall should be disabled, this is provided that you havent changed it on a group policy lower down.

when you shutdown the station the firewall will disable.

I have just tested this in my lab and it works :0)

/Fox

0
 
JAKJOAuthor Commented:
Hi Fox,

It still doesn't seem to work and the firewall is enabled. Incase I have missed something. Here is what I have done (btw, do any script perameters need to be set?)
Created a test OU and put the test laptop in to the OU. Created a new policy and called it laptop firewall test.
Copied the pasted the scripts you gave me and attached them respecitvely to the startup and shut down. Rebooted Laptop and windows firewall is enabled both on logging on the domain and also locally.

Thanks
0
 
knightfoxCommented:
are you setting this with a GPO anywhere else??? can you run them manually on the station??

\\domain\sysvol\scripts\disable firewall.vbs

is the firewall disabled?
0
 
JAKJOAuthor Commented:
Hi

This is the error I get when I try to run them manually.
Script.jpg
0
 
knightfoxCommented:
I think i see...

are you running client firewall software??? please disable this and try again.

/Fox
0
 
JAKJOAuthor Commented:
There is no client firewall software, apart from Windows firewall.
Do you mean my anti virus client?
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 5
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now