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
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
L.
yes they are all windows VDI windows 10
Can you use appinfo?
Are all prereqs met?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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