Just want to streamline this code a little, it does what I need it to do but think it can be smoother.
So I query all installed apps on a x64 Win 7 box, creates an array, I check if the array contains the program I'm looking for and if true do nothing else install program. Is using IF the best way, cleanest way?
I'm integrating it into the app deployment toolkit as there are a number of applications I have to install that required multiple components and want to make sure it checks if needed or not (during some testing it failed when the application was already installed). Code just looks messy. (Write-host is only there for testing to make sure it does what I need it to do)
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Hey
Just want to streamline this code a little, it does what I need it to do but think it can be smoother.
So I query all installed apps on a x64 Win 7 box, creates an array, I check if the array contains the program I'm looking for and if true do nothing else install program. Is using IF the best way, cleanest way?
I'm integrating it into the app deployment toolkit as there are a number of applications I have to install that required multiple components and want to make sure it checks if needed or not (during some testing it failed when the application was already installed). Code just looks messy. (Write-host is only there for testing to make sure it does what I need it to do)
set-location HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
$appLists = Get-ChildItem | foreach-object { $_.GetValue("DisplayName")} | sort -unique
$checkInstalled = $appLists -contains "orca"
if($checkInstalled -eq $true){
write-host "its installed"
}
else{
write-host "install program"
}
Any help would be appreciated.
Thanks everyone.
Chongy.
Share this post
Link to post
Share on other sites