So here's the script and data as I have them and while not 100% correct
with the output it's close enough until I can figure it out properly.
#!powershell
# WANT_JSON
$path = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs"
$items = Get-ChildItem -Recurse -Path $path -Include *.lnk
$Shell = New-Object -ComObject WScript.Shell
$result = @{
changed = $false
installed_progs = @()
}
foreach ($item in $items) {
$object = new-object psobject @{
name = $item.BaseName.tolower()
path = $Shell.CreateShortcut($item).targetpath.tolower()
}
if ($object.path.endswith('exe') -and $object.path -like "*Program*") {
$result.installed_progs+=$object
}
}
[Runtime.InteropServices.Marshal]::ReleaseComObject($Shell) | Out-Null
echo $result | convertto-json -compress -depth 99
and the play that I run to get the data out as I am doing it via module
---
- name: Get Installed Programs with Versions
hosts: testing
# no_log: true
gather_facts: FALSE
tasks:
- name: Get Installed Applications
action: getInstalledPrograms
register: applications
- debug: var=applications
- name: Check Application Version
win_file_version:
path: "{{ item.path }}"
no_log: false
register: exe_file_version
with_items:
- "{{ applications.installed_progs }}"
- debug: var="{{ item }}"
no_log: false
with_items: "{{ exe_file_version.results }}"
and the output that I have at the moment
ok: [REMOVED] => {
"applications": {
"changed": false,
"installed_progs": [
{
"name": "7-zip file manager",
"path": "c:\\program files\\7-zip\\7zfm.exe"
},
}
}
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/d938abf8-d831-468e-8d96-17492f6fcde3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.