Skip to content

Instantly share code, notes, and snippets.

@xsolon
Created October 21, 2017 16:49
Show Gist options
  • Select an option

  • Save xsolon/e2449128e21a0e9abe8666380faebc14 to your computer and use it in GitHub Desktop.

Select an option

Save xsolon/e2449128e21a0e9abe8666380faebc14 to your computer and use it in GitHub Desktop.
DSC Firewall rules for sql instance using dynamic ports
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