Created
October 21, 2017 16:49
-
-
Save xsolon/e2449128e21a0e9abe8666380faebc14 to your computer and use it in GitHub Desktop.
DSC Firewall rules for sql instance using dynamic ports
This file contains hidden or 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
| Configuration SqlFirewallApp2 | |
| { | |
| #Import-DscResource -ModuleName PSDesiredStateConfiguration | |
| Import-DSCResource -ModuleName xNetworking | |
| node $env:ComputerName | |
| { | |
| # instance rule | |
| xFireWall SQLFirewallRule | |
| { | |
| Name = "SqlApp2" | |
| DisplayName = 'Sql - App2' | |
| Group = 'DSC Configuration Rules' | |
| Ensure = 'Present' | |
| Enabled = 'True' | |
| Profile = ('Domain') # ,'Private' | |
| Direction = 'InBound' | |
| Protocol = 'TCP' | |
| Program = 'E:\sql\MSSQL12.APP2\MSSQL\Binn\sqlservr.exe' | |
| Description = 'Firewall Rule to allow SQL communication' | |
| } | |
| # dynamic port resolve rule | |
| xFireWall SQLFirewallRuleDynamicPortResolution | |
| { | |
| Name = "SqlDynamicPortQuery" | |
| DisplayName = 'Sql Dynamic Port Query' | |
| Group = 'DSC Configuration Rules' | |
| Ensure = 'Present' | |
| Enabled = 'True' | |
| Profile = ('Domain') # ,'Private' | |
| Direction = 'InBound' | |
| Protocol = 'UDP' | |
| LocalPort = ('1434') | |
| Description = 'Firewall Rule to allow SQL communication' | |
| } | |
| } | |
| } | |
| SqlFirewallApp2 | |
| Start-DSCConfiguration -ComputerName $env:ComputerName -Path .\SqlFirewallApp2 -Wait -Verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment