Trying to find a version of Vmware software installed on a server. Using the following command to query the server’s registry I get the information needed. I just want two values, the name of the software and the version. This is contained in a noteproperty named property.
This is the command I am using
"","Wow6432Node" | ForEach-Object {Get-ChildItem HKLM:\SOFTWARE\$_\Microsoft\Windows\CurrentVersion\Uninstall\ | ? {($_.GetValue("DisplayName")) -like "*VMware*"}}
This is a sample of the output:
Hive: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Name Property
---- --------
{F32C4E7B-2BF8-4788-8408-824C6 AuthorizedCDFPrefix :
896E1BB} Comments : Build
Contact :
DisplayVersion : 10.3.5.10430147
HelpLink :
HelpTelephone :
InstallDate : 20190314
InstallLocation : C:\Program Files\VMware\VMware Tools\
InstallSource : C:\Program Files\Common Files\VMware\InstallerCache\
ModifyPath : MsiExec.exe /I{F32C4E7B-2BF8-4788-8408-824C6896E1BB}
NoRepair : 1
Publisher : VMware, Inc.
Readme :
Size :
EstimatedSize : 80288
UninstallString : MsiExec.exe /I{F32C4E7B-2BF8-4788-8408-824C6896E1BB}
URLInfoAbout :
URLUpdateInfo :
VersionMajor : 10
VersionMinor : 3
WindowsInstaller : 1
Version : 167968773
Language : 1033
DisplayName : VMware Tools
Hive: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
Name Property
---- --------
{2E4FAF13-B720-4385-A23C-5C38D AuthorizedCDFPrefix :
742D6C6} Comments :
Contact :
DisplayVersion : 6.5.0.234
HelpLink :
HelpTelephone :
InstallDate : 20180927
InstallLocation : E:\Tools\PowerCLI\
InstallSource : C:\Users\sa00498\AppData\Local\Downloaded
Installations\vSpherePowerCLI\{49AEB26E-F52E-46C1-9345-6E463CAA115B}\
ModifyPath : MsiExec.exe /I{2E4FAF13-B720-4385-A23C-5C38D742D6C6}
Publisher : VMware, Inc.
Readme :
Size :
EstimatedSize : 255892
UninstallString : MsiExec.exe /I{2E4FAF13-B720-4385-A23C-5C38D742D6C6}
URLInfoAbout : http://www.vmware.com
URLUpdateInfo :
VersionMajor : 6
VersionMinor : 5
WindowsInstaller : 1
Version : 100990976
Language : 1033
DisplayName : VMware PowerCLI
sEstimatedSize2 : 181988
How do I get the DisplayName and DisplayVersion from that NoteProperty? I will need to do this against a list of servers, but first I have to figure this step out. Any help is appreciated. And if you could explain why your suggestion works that would be helpful too.
Thanks
I use this
Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
ForEach-Object { Get-ItemProperty $.pspath } |
Where-Object {$.Displayname -like ‘citrix’} |
Select-Object PSChildName, DisplayName, DisplayVersion,UninstallString, PSPath |
Sort-Object PSChildName, DisplayName, DisplayVersion,UninstallString, PSPath |Select-Object DisplayName, DisplayVersion | Format-List
or this
Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
ForEach-Object { Get-ItemProperty $.pspath } |
Where-Object {$.Displayname -like ‘citrix’} |
Select-Object PSChildName, DisplayName, DisplayVersion,UninstallString, PSPath |
Sort-Object PSChildName, DisplayName, DisplayVersion,UninstallString, PSPath | Select-Object -expand DisplayName
You can go straight to get-itemproperty with a wildcard:
# estimated size in kb
$(get-itemproperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*
get-itemproperty HKLM:\SOFTWARE\wow6432node\Microsoft\Windows\CurrentVersion\Uninstall\*) |
where displayname -like v* |
select DisplayName, DisplayVersion, EstimatedSize, InstallLocation,
@{n='PSPath';e={$_.PSPath -replace 'Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE','HKLM:'}} |
sort | ft
DisplayName DisplayVersion EstimatedSize InstallLocation PSPath
----------- -------------- ------------- --------------- ------
Vulkan Run Time Libraries 1.0.33.0 1.0.33.0 1700 HKLM:\software\microsoft\windows\currentversion\uninstall\VulkanRT...
Vulkan Run Time Libraries 1.0.33.0 1.0.33.0 1700 HKLM:\software\microsoft\windows\currentversion\uninstall\VulkanRT...
Thank you. Works like a charm!
Now I have to look at each line and figure out what is happening under the covers
Much appreciated
The simplest way is to pipe the result into Get-ItemProperty
to translate the registry item into a more standard PowerShell object with easily-accessible properties. From there, you can use Select-Object -Property
to trim down the properties to just the ones you’re interested in.
foreach ($item in "","Wow6432Node") {
Get-ChildItem "HKLM:\SOFTWARE\$item\Microsoft\Windows\CurrentVersion\Uninstall\" |
Get-ItemProperty |
Where-Object DisplayName -like "*VMware*" |
Select-Object -Property DisplayName, DisplayVersion
}
'','Wow6432Node' |ForEach-Object {
Get-ItemProperty HKLM:\SOFTWARE\$_\Microsoft\Windows\CurrentVersion\Uninstall\VMware* |
Select-Object DisplayName,DisplayVersion
}
or
'','Wow6432Node' |ForEach-Object {
Get-ItemProperty HKLM:\SOFTWARE\$_\Microsoft\Windows\CurrentVersion\Uninstall\* |
Where-Object -Property DisplayName -like '*VMware*' |
Select-Object DisplayName,DisplayVersion
}
The Get-ItemProperty
works better with the registry and get all of the properties of the give path in a readable format. Then you can use Select-Object
to output the properties to the console.
pwshliquori