PowerShell script exchange
Post Reply
jrwilmoth040707
Service Provider
Posts: 154
Liked: 16 times
Joined: Apr 07, 2015 1:53 pm
Full Name: James Wilmoth
Contact:

Firewall rule creation script

Post by jrwilmoth040707 »

I think ideally this could be a feature request for a collection of cmdlets that can be invoked from the BNR server on itself or to remote assets in the deployment. A few times now, I have run into a situation where I want to reset the Windows firewall to default to try and eliminate a symptom, but I am loath to do that because I would have to recreate all the Veeam firewall rules. I would love to drop into Veeam's PowerShell module and invoke something like "Set-DefaultFirewallRules" or "New-DefaultFirewallRules" etc.

oleg.feoktistov
Veeam Software
Posts: 446
Liked: 138 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Firewall rule creation script

Post by oleg.feoktistov »

If you are talking about a programmatic implementation of the native setting for Windows firewall defaults ("Restore defaults" or "Restore default policy"), just invoke the command below:

Code: Select all

(New-Object -ComObject HNetCfg.FwPolicy2).RestoreLocalFirewallDefaults()
If you want to restore your custom rules back, combine it with export/import approach:

Code: Select all

netsh advfirewall export "C:\Temp\fwPolicy.wfw"
netsh advfirewall import "C:\Temp\fwPolicy.wfw"
Thanks!

oleg.feoktistov
Veeam Software
Posts: 446
Liked: 138 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Firewall rule creation script

Post by oleg.feoktistov »

Or you're talking about resetting and setting back only Veeam rules all at once?

soncscy
Expert
Posts: 179
Liked: 67 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey Carel
Contact:

Re: Firewall rule creation script

Post by soncscy »

Doesn't Veeam already try to do this for its Windows components? At least on install I guess...is there a way to call the same logic via powershell?

oleg.feoktistov
Veeam Software
Posts: 446
Liked: 138 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Firewall rule creation script

Post by oleg.feoktistov »

Yes, you can change management port for each server component:

Code: Select all

$server = Get-VBRServer -Name <HostName>
$physHost = $server.GetPhysicalHost()
$components = $physHost.GetComponents()
$port = 6161
$components[0].SetMgmtPort($port) 
However, I believe James is asking about a possibility to operate over Veeam-specific firewall rules with a collection of custom cmdlets.

jrwilmoth040707
Service Provider
Posts: 154
Liked: 16 times
Joined: Apr 07, 2015 1:53 pm
Full Name: James Wilmoth
Contact:

Re: Firewall rule creation script

Post by jrwilmoth040707 »

Apologies, I must not have been clear. Yes, I mean only the Veeam rules. I want to be able to reset the Windows firewall which will clear all non-standard rules. Then I would like to invoke a quick Veeam cmdlet to recreate the Veeam-specific rules.

oleg.feoktistov
Veeam Software
Posts: 446
Liked: 138 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Firewall rule creation script

Post by oleg.feoktistov »

James, I noted your feature request. However, it can be written outside Veeam Snap-in.
Let me see if I can write a wrapper for that. Stay tuned. Oleg

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests