Last active
February 17, 2016 08:16
-
-
Save tomtorggler/64bf5b6c92313b8d7815 to your computer and use it in GitHub Desktop.
Create NetFirewall Rules for SQL Server and SQL Browser executables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get SQL services and path to executable | |
$services = Get-CimInstance -query 'select * from win32_service where name="sqlbrowser" or name="mssqlserver"' | |
# Create Firewall Rule for each of the services executables | |
# use splatting for better readability | |
foreach ($service in $services) { | |
$params = @{ | |
DisplayName = $service.Name; | |
Action = "Allow"; | |
Description ="Allow $($service.name)"; | |
Enabled = 1; | |
Profile = "Any"; | |
Program = $service.pathname.replace('"','') | |
} | |
New-NetFirewallRule @params | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment