VMware Cloud Community
fborges555
Enthusiast
Enthusiast

find specific software on VM

HI gurus

I am looking for a script to help me find a specific software installed on a VM, I read about looking into the registry, is this the best and most efficient way to obtain this information?

 

Thanks a bunch

0 Kudos
5 Replies
LucD
Leadership
Leadership

I assume these are all VMs running a Windows guest OS?

If you have the VMware Tools 11 installed inside the Guest OS and you are on vSphere 7.*, you could use the appinfo feature, see Application Discovery in vSphere with VMware Tools 11


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

 

yes they are all windows VDI windows 10

Tags (1)
0 Kudos
LucD
Leadership
Leadership

Can you use appinfo?
Are all prereqs met?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast

L.

 

Not all of them , I can see there are a lot of the machine that are VMT 11 but some are VMT 10 for that matter.

 

so for some the pre-req is ok for other is not

 

Thanks again

 

 

0 Kudos
LucD
Leadership
Leadership

Ok, in that case, you will have to query the registry.
To get a list of all installed SW use something like this

$code = @'
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall',
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' |
ForEach-Object -Process {
  Get-ChildItem -Path $_ |
  ForEach-Object -Process {
    Get-ItemProperty -Path $_.Name.Replace('HKEY_LOCAL_MACHINE', 'HKLM:') |
    Select-Object DisplayName, DisplayVersion
  }
} | ConvertTo-Csv
'@

Get-VM -PipelineVariable vm |
Where-Object { $_.PowerState -eq 'PoweredOn' -and $_.Guest.OSFullName -match 'Windows' } |
ForEach-Object -Process {
    $result = Invoke-VMScript -VM $vm -ScriptText $code -ScriptType Powershell
    $result.ScriptOutput | ConvertFrom-Csv |
    where{$_.DisplayName -ne ''} |
    ForEach-Object -Process {
        $_ | Add-Member -Name VM -Value $vm.Name -MemberType NoteProperty -PassThru
    }
}

 

In case you are looking for a specific application you could do.

$appName = 'VMware Tools'

$code = @'
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall',
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' |
ForEach-Object -Process {
  Get-ChildItem -Path `$_ |
  ForEach-Object -Process {
    Get-ItemProperty -Path `$_.Name.Replace('HKEY_LOCAL_MACHINE', 'HKLM:') |
    where{`$_.DisplayName -match '$appName'} |
    Select-Object DisplayName, DisplayVersion
  }
} | ConvertTo-Csv
'@

Get-VM -PipelineVariable vm |
Where-Object { $_.PowerState -eq 'PoweredOn' -and $_.Guest.OSFullName -match 'Windows' } |
ForEach-Object -Process {
    $result = Invoke-VMScript -VM $vm -ScriptText $ExecutionContext.InvokeCommand.ExpandString($code) -ScriptType Powershell
    $result.ScriptOutput | ConvertFrom-Csv |
    where{$_.DisplayName -ne ''} |
    ForEach-Object -Process {
        $_ | Add-Member -Name VM -Value $vm.Name -MemberType NoteProperty -PassThru
    }
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos