Octopus.Script exported 2014-05-16 by bobjwalker belongs to ‘Windows’ category.
Configures a firewall rule
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Rule name
RuleName
The name of the rule
Local Port
LocalPort
The comma separated list of local port values
Remote Port
RemotePort = any
The comma separated list of remote port values
Protocol
Protocol = TCP
The protocol for the rule. Commonly either ‘TCP or ‘UDP’
Direction
Direction
The rule direction. Either ‘in’ or ‘out’
Script body
Steps based on this template will execute the following PowerShell script.
$ruleName = $OctopusParameters['RuleName']
$localPort = $OctopusParameters['LocalPort']
$remotePort = $OctopusParameters['RemotePort']
$protocol = $OctopusParameters['Protocol']
$direction = $OctopusParameters['Direction']
# Remove any existing rule
Write-Host "Removing existing rule"
netsh advfirewall firewall delete rule name="$ruleName" dir=$direction
# Add new rule
Write-Host "Adding new rule"
netsh advfirewall firewall add rule name="$ruleName" dir=$direction action=allow protocol=$protocol localport=$localPort remoteport=$remotePort
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "e47a9558-e49c-44a6-ae8f-66372b285789",
"Name": "Windows Firewall - Configure Rule",
"Description": "Configures a firewall rule",
"Version": 4,
"ExportedAt": "2014-05-16T10:13:17.207+00:00",
"ActionType": "Octopus.Script",
"Author": "bobjwalker",
"Parameters": [
{
"Name": "RuleName",
"Label": "Rule name",
"HelpText": "The name of the rule",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "LocalPort",
"Label": "Local Port",
"HelpText": "The comma separated list of local port values",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "RemotePort",
"Label": "Remote Port",
"HelpText": "The comma separated list of remote port values",
"DefaultValue": "any",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "Protocol",
"Label": "Protocol",
"HelpText": "The protocol for the rule. Commonly either 'TCP or 'UDP'",
"DefaultValue": "TCP",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Name": "Direction",
"Label": "Direction",
"HelpText": "The rule direction. Either 'in' or 'out'",
"DefaultValue": null,
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
}
],
"Properties": {
"Octopus.Action.Script.ScriptBody": "$ruleName = $OctopusParameters['RuleName']\n$localPort = $OctopusParameters['LocalPort']\n$remotePort = $OctopusParameters['RemotePort']\n$protocol = $OctopusParameters['Protocol']\n$direction = $OctopusParameters['Direction']\n\n# Remove any existing rule\n\nWrite-Host \"Removing existing rule\"\nnetsh advfirewall firewall delete rule name=\"$ruleName\" dir=$direction\n\n# Add new rule\n\nWrite-Host \"Adding new rule\"\nnetsh advfirewall firewall add rule name=\"$ruleName\" dir=$direction action=allow protocol=$protocol localport=$localPort remoteport=$remotePort",
"Octopus.Action.Script.Syntax": "PowerShell"
},
"Category": "Windows",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/windows-firewall-configure-rule.json",
"Website": "/step-templates/e47a9558-e49c-44a6-ae8f-66372b285789",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRF////Da3qSsLvhtb0wur6O7zuWcfxldv2aMzyK7ftpOD3s+X48Pr+0fD7d9HzHLLr4fX8xD/OcwAAAaNJREFUeNrs3cFygjAUQFECWott1f//2sJoW6kIKEzNs+euXOmcmSSGDa8oJEmSJEmSJGmsj1W1K9cpsGD1Vr2WdToVEPC+2lYvZfpVrEW0qZpF1F+MRdRugzoNlvkiarfBPk0pT8GhWUSX2yASpDlLr2+DEJBmEY1ug6whx7N0n2b30G1QlmmxHsRYp6X76yvF9vg5RYQczq8UVURI35UiFmTgShED0p6lI1eKzCHTrxS5Qk6PZ9PLDtJ9PIsJmXWlyAky6/dAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQMJCyjltF/iO3gpJUpD8s4OAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8T8itwwKyhbTdMr4ha8hXUwZqhICcOgyNOIkE+V5wo4MSgr1u/fp7poO+AL8K/gL8yw0UeyRB34m9iQ/pVD8L5JYTO3NI58R+AsiEEzsW5OfE3sUe/zRwYkeGnG2g2CPS7rhjF4GKP0ZwyoldxK37kFqEL/7wU0mSJEmSJOmJ+xRgAHxZTCXGdZkfAAAAAElFTkSuQmCC",
"$Meta": {
"Type": "ActionTemplate"
}
}
Page updated on Friday, May 16, 2014