I want to address the table-formated output of my function like an object, i.e. the row [2] column 'Action' should be addressable like $r[2].Action. How can I do that?
I tried using 'ConvertFrom-SourceTable' from the powershellgallery, but that didn't work. And I'd rather have a simple solution without extra installs.
Function Get-NetFirewallRulesByPort { Param ( [Parameter(Mandatory=$true)] [ValidateRange(1,65535)] [int] $port ) Get-NetFirewallRule | where { ($_ | Get-NetFirewallPortFilter).LocalPort -eq ${port} } | select Enabled, Action, Direction, DisplayName | ft -AutoSize } # usage: $r = (Get-NetFirewallRulesByPort 443) $r # required: Write-Host $r[2].Action Write-Host $r[1].DisplayName # etc. ...