I'm having a heck of a time pulling a report for ports, and then adding the rule display name and other information to it.
Input a port number
Something is wrong with my logic, and of course the code. After staring at the screen non-stop to get this worked out, I am finally fried after three days.
Any help in the right direction is appreciated.
$Script:Rules = Get-NetFirewallRule -policystore ActiveStore | Where-object ((Enabled -eq "True") -and (Action -eq "Allow"))
$Script:PortFilter = $Script:Rules | get-netfirewallportfilter -PolicyStore ActiveStore | Where-Object localport -eq $Script:Portos
Foreach ($Script:One in $Script:PortFilter)
$DasRemoteIps = $Script:One |
$DasRuleName = $Script:One |
Please review the instructions above the posting textbox for code formatting – [square brackets] aren't usable here.
You should also, over time, investigate emitting a custom object rather than a bunch of strings. As-is, the data you're outputting is going to be pretty much limited to screen display. "The PowerShell Scripting & Toolmaking Book" is a good resource (I'm biased) for getting into the "PowerShell way" of doing this. Those $script: modifiers are also unnecessary and are going to get you in to trouble.
Now... where do you see it going wrong? Like, can you set breakpoints after each variable assignment, check the variable's new contents, and see where things stop going as you expect?
You must be logged in to reply to this topic.