new to stackoverflow. Have been a lurker for years but now need help. I am writing a simple script for an MSP to detect for a base set of applications and if not installed to run the chocolatey install command for that app. When I run this in ISE as an admin it reports back true for all the variable values even if it is not true. If I run just the test-path and tell it to write-host the value it is correct. But when ran all together it always comes back True. Can someone help investigate for me?
#Are programs installed?
$a = Test-Path "C:\Program Files\7-Zip" IF ($a = "True") {Write-Host "7-zip is installed"} ELSE {Write-Host "7-zip is not installed, install command sent" choco install 7zip -y}
$b = Test-Path "C:\Program Files\Mozilla Firefox" IF ($b = "True") {Write-Host "Firefox is installed"} ELSE {Write-Host "Firefox is not installed, install command sent"}
$c = Test-Path "C:\Program Files (x86)\Adobe\Acrobat Reader DC" IF ($c = "True") {Write-Host "Adobe Reader is installed"} ELSE {Write-Host "Adobe Reader is not installed, install command sent"}
$d = Test-Path "C:\Program Files (x86)\Google\Chrome" IF ($d = "True") {Write-Host "Chrome is installed"} ELSE {Write-Host "Chrome is not installed, install command sent"}