Q:

Retrieve software that has been authorized to pass through firewall in powershell

The code below turns off firewall on each remote computers and return any computers that was turned off. I am also trying to retrieve software that has been authorized to pass through firewall for each computer.
I understand that I am using try, catch so is there any way to print the output of $Appfilter to offComp&programsALLO.txt ? The text file just prints the value of $Appfilter. 
The output should ideally look like:
Computers:
"name of computer" followed by "programs allowed"

Here is the code:
Get-ADComputer -Filter * | Select-Object -ExpandProperty Name | Out-File .\ADcomputers.txt

$LaunchLine = 'powershell.exe -Version 4.0 -Command "& {netsh advfirewall set allprofiles state off}"'
$Appfilter = 'powershell.exe -Version 4.0 -Command "& {Get-NetFirewallApplicationFilter -program * | fl program}"'
$ComputerList = Get-Content .\adcomputers.txt

foreach($Computer in $ComputerList) {
    [String]$wmiPath = "\\{0}\root\cimv2:win32_process" -f $computer

    try {
        [wmiclass]$Executor = $wmiPath
        $executor.Create($LaunchLine, $Appfilter)
    } catch {
        Add-Content offComp&programsALLO.txt "computers:$Computer, $Appfilter "
    }
}

A:

I would use Invoke-Command with the -ComputerName parameter if possible:
#store AD Computer names in an array
$computerList = (Get-ADComputer -Filter *).Name

#declare results arrays
$results = @()
$offline = @()

#for each computer
foreach($computer in $computerList) {

    #if computer responds to ping
    if(Test-Connection $computer -Count 2 -Quiet -ErrorAction SilentlyContinue) {

        #disable firewall
        Invoke-Command -ComputerName $computer -ScriptBlock {
            netsh advfirewall set allprofiles state off
        } | Out-Null

        #store retrieved authorized programs list in an array
        $programs = Invoke-Command -ComputerName $computer -ScriptBlock {
            (Get-NetFirewallApplicationFilter).Program
        }

        #build results object and add it to results array
        $results += [PSCustomObject]@{
            ComputerName = $computer
            Programs = $programs -join ";"    
        }
    } else {
        #build results object and add it to offline array
        $offline += [PSCustomObject]@{
            ComputerName = $computer
            Status = "OFFLINE"    
        }
    }
}

#export results to files
$results | Out-File "report.txt"
$offline | Out-File "offline.txt"

