Hi there,
I’m a newbie and I’ve been struggeling with this challenge for a couple of days now.
I’ve used an excellent code I found on Github to parse Windows Firewall logs.
I’ve successfully added a DNS lookup based on IP adress and now I also would like to add the computer description based on IP address. But for some reason I’m not able to get the description to work.
This is the column which fails:
@{Name=“src-desc”;Expression={ (Get-ADComputer -Filter {IPv4Address -eq $_.“src-ip”} -Property description).description}} ,
Any suggestions? Thx in advance
####Begin of code
function Get-WindowsFirewallLog {
param(
[parameter(Position=0,Mandatory=$false)]
[ValidateScript({Test-Path $_})]
[string]$LogFilePath = “$env:SystemRoot\System32\LogFiles\Firewall\pfirewall.log”
)
# CSV header fields, to be used later when converting each line of the tailed log from CSV
$headerFields = @("date","time","action","protocol","src-ip","dst-ip","src-port","dst-port","size","tcpflags","tcpsyn","tcpack","tcpwin","icmptype","icmpcode","info","path")
# Read in the firewall log
$firewallLogs = Get-Content $LogFilePath | ConvertFrom-Csv -Header $headerFields -Delimiter ' '
# Output logs into a gridview
$firewallLogs | select-object -property "protocol","src-ip",@{Name="src-fqdn";Expression={ ([System.Net.Dns]::GetHostEntry($_."src-ip").HostName)}} ,@{Name="src-desc";Expression={ (Get-ADComputer -Filter {IPv4Address -eq $_."src-ip"} -Property description).description}} ,"src-port","dst-ip",@{Name="dst-fqdn";Expression={ ([System.Net.Dns]::GetHostEntry($_."dst-ip").HostName)}} ,"dst-port","path" |OUT-GRIDVIEW
}
Get-WindowsFirewallLog
####End of code