0

Script is to search a computer with a specific name to the specified .exe or .msi file/application. To my knowledge the commented out .msi line works, but the .exe line does not. In this example I am trying to find "Firefox". If the file/application is found it should display the Version. If the file/application is not found it should display "does not have this application."

If you can fix it PLEASE fix my code and post it.

$ADObjects = Get-ADComputer -filter {(name -like "PC Name goes here")};

$ADObjects | ForEach {
    $computerName = $_.name;
    Write-Output $computerName;
    #$Versions = (Get-WmiObject -Class Win32_Product -ComputerName $computerName| Where-Object {$_.name -like "FireFox"});   # Finds .msi programs
    $Versions = (ComputerName $computerName| Where-Object { $_.Name -Like 'Firefox*' }); # Trying to find .exe programs
    $Count = ($Versions | Measure-object).count;
    if ($Count -eq 0) {
        Write-Output "$computerName does not have this application.";
    }
    else {
    
        Write-Output $Versions;

        #$Versions.unistall();    # Uncommenting this line will uninstall the versions listed by the line above
    }
}
Cap Stone
  • 25
  • 6
  • 2
    There is nothing in your code that actually searches for a file. See here for how to do that: [Recursive file search using PowerShell](https://stackoverflow.com/questions/8677628/recursive-file-search-using-powershell) – Gabriel Luci Jan 22 '22 at 17:09
  • Here's a better [solution](https://adamtheautomator.com/powershell-list-installed-software/). – Abraham Zinala Jan 22 '22 at 17:32
  • 1
    if you are ACTUALLY looking for installed app info, then you likely otta use the new[er] `Get-Package` cmdlet. something like this >>> `Get-Package -Name *firefox*` << – Lee_Dailey Jan 22 '22 at 18:53

0 Answers0