Jump to content


  • 0
Chongy

Powershell, check application not installed, install if not

Question

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

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

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.