I wrote a short script to uninstall a program on multiple computers (from a text doc of hostnames). The script is working as expected but is taking about 2-3 minutes per host. Is there a way to perform this on all the machines simultaneously?
Here's my script.
$computers = Get-Content C:\Computernames.txt
foreach($Computer in $computers){
    Invoke-Command -ComputerName $Computer -ScriptBlock{
    
    $application = Get-WmiObject -Class Win32_Product -Filter "Name LIKE '%Appname%'"
    #uninstall the app if it exists
    if($application){
        $application.Uninstall()
        Write-Output "Application uninstalled successfully.."
    }
    else{
        Write-Output "Application not found.."
    }
    } 
}
Can I do Invoke-Command -ComputerName $Computers and do all machines simultaneously to avoid looping through?