0

I have a PowerShell script that finds what version of Java is installed by checking the registry but the script has Java hard coded into it and I would like to be able to change it to Adobe, or Google at will by passing a variable into salt * cmd.script.

$application = "Java*"

$applicationList = @()

$applicationList += `

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | `
Where-Object -Property DisplayName -like $application | `
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate

$applicationList += `

Get-ItemProperty HKLM:\Software\WOW6432node\Microsoft\Windows\CurrentVersion\Uninstall\* | `
Where-Object -Property DisplayName -like $application | `
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate

Return $applicationList

The goal is to find if and what version of Java or Google Chrome has been installed on a server/minion while minimizing the amount of terminal output.
Other methods I have tried give me info about ALL applications and not just the one I want to know about.

I imagine something like:

salt -G os:Windows cmd.script salt://scripts/Applications.ps1 var='{"applications": "Google"}'

Trying to come up with something that is elegant and quick. PS, I am not a developer.

  • Would your salt -G os:Windows cmd.script salt://scripts/Applications.ps1 line work with hard-coded $application = "Java*" ( note omitted var=… part)? – JosefZ Apr 23 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.