@ -48,9 +48,9 @@ function Parse-Action {
# Profile enum values: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366303(v=vs.85).aspx
function Parse-Profiles
{
param ( $profiles Str )
param ( $profiles List )
$profiles = ( $profiles Str. Split ( ',' ) | Select -uniq | ForEach {
$profiles = ( $profiles List | Select -uniq | ForEach {
switch ( $_ ) {
" domain " { return 1 }
" private " { return 2 }
@ -65,9 +65,9 @@ function Parse-Profiles
function Parse-InterfaceTypes
{
param ( $interfaceTypes Str )
param ( $interfaceTypes )
return ( $interfaceTypes Str. Split ( ',' ) | Select -uniq | ForEach {
return ( $interfaceTypes | Select -uniq | ForEach {
switch ( $_ ) {
" wireless " { return " Wireless " }
" lan " { return " Lan " }
@ -117,8 +117,8 @@ function New-FWRule
[ string ] $direction ,
[ string ] $action ,
[ bool ] $enabled ,
[ string ] $profiles ,
[ string ] $interfaceTypes ,
[ string [] ] $profiles ,
[ string [] ] $interfaceTypes ,
[ string ] $edgeTraversalOptions ,
[ string ] $secureFlags
)
@ -137,8 +137,8 @@ function New-FWRule
if ( $remoteAddresses -and $remoteAddresses -ne " any " ) { $rule . RemoteAddresses = $remoteAddresses }
if ( $direction ) { $rule . Direction = Parse-Direction -directionStr $direction }
if ( $action ) { $rule . Action = Parse-Action -actionStr $action }
if ( $profiles ) { $rule . Profiles = Parse-Profiles -profiles Str $profiles }
if ( $interfaceTypes -and $interfaceTypes -ne " any " ) { $rule . InterfaceTypes = Parse-InterfaceTypes -interfaceTypes Str $interfaceTypes }
if ( $profiles ) { $rule . Profiles = Parse-Profiles -profiles List $profiles }
if ( $interfaceTypes -and @ ( Compare-Object $interfaceTypes @ ( " any " ) ) . Count -ne 0 ) { $rule . InterfaceTypes = Parse-InterfaceTypes -interfaceTypes $interfaceTypes }
if ( $edgeTraversalOptions -and $edgeTraversalOptions -ne " no " ) {
# EdgeTraversalOptions property exists only from Windows 7/Windows Server 2008 R2: https://msdn.microsoft.com/en-us/library/windows/desktop/dd607256(v=vs.85).aspx
if ( $rule | Get-Member -Name 'EdgeTraversalOptions' ) {
@ -172,18 +172,22 @@ $action = Get-AnsibleParam -obj $params -name "action" -type "str" -failifempty
$program = Get-AnsibleParam -obj $params -name " program " -type " str "
$service = Get-AnsibleParam -obj $params -name " service " -type " str "
$enabled = Get-AnsibleParam -obj $params -name " enabled " -type " bool " -default $true -aliases " enable "
$profiles = Get-AnsibleParam -obj $params -name " profiles " -type " str " -default " domain ,private,public" -aliases " profile "
$profiles = Get-AnsibleParam -obj $params -name " profiles " -type " li st" -default @ ( " domain " , " private" , " public" ) -aliases " profile "
$localip = Get-AnsibleParam -obj $params -name " localip " -type " str " -default " any "
$remoteip = Get-AnsibleParam -obj $params -name " remoteip " -type " str " -default " any "
$localport = Get-AnsibleParam -obj $params -name " localport " -type " str "
$remoteport = Get-AnsibleParam -obj $params -name " remoteport " -type " str "
$protocol = Get-AnsibleParam -obj $params -name " protocol " -type " str " -default " any "
$interfacetypes = Get-AnsibleParam -obj $params -name " interfacetypes " -type " str " -default " any "
$interfacetypes = Get-AnsibleParam -obj $params -name " interfacetypes " -type " li st" -default @ ( " any " )
$edge = Get-AnsibleParam -obj $params -name " edge " -type " str " -default " no " -validateset " no " , " yes " , " deferapp " , " deferuser "
$security = Get-AnsibleParam -obj $params -name " security " -type " str " -default " notrequired " -validateset " notrequired " , " authnoencap " , " authenticate " , " authdynenc " , " authenc "
$state = Get-AnsibleParam -obj $params -name " state " -type " str " -default " present " -validateset " present " , " absent "
$force = Get-AnsibleParam -obj $params -name " force " -type " bool " -default $false
if ( $force ) {
Add-DeprecationWarning -obj $result -message " 'force' isn't required anymore " -version 2.9
}
if ( $diff_support ) {
$result . diff = @ { }