Author Posts

December 27, 2013 at 10:09 am

I am having trouble how to figure out how to access the items in the programs and features with powershell on server 2003. I currently have a script that will check if a specific application is installed under programs and then execute more commands after that, this is on server 2008.

$checkMSI = (Get-WmiObject -Query 'SELECT * from win32_product where IdentifyingNumber = "{E876A5DA-9506-4F94-A304-E032CB53E970}"').IdentifyingNumber

unfortunately the class "win32_product" is not available in server 2003.

Any help would be appreciated : ).

December 27, 2013 at 10:16 am

Win32_Product is a separate install in Win2003. You should find it on any Win2003 install DVD under the Support or Tools folder.

December 27, 2013 at 10:24 am

Ok, thank you very much. In my environment I have alot of servers that are in facilities out of state so I dont have immediate access to them to go ahead and install this addition to them, do you know of any other way to access the control panel in 2003? Or is this by far the easiest route.

December 27, 2013 at 11:16 am

I wouldn't recommend using Win32_Product even if you had it available. See this blog post for the details on why:

All of the information that you need to reproduce Win32_Product's behavior (without the annoying side effects) can be found in the registry, mostly under the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\ . This covers software that was installed with a Windows Installer package. Other, non MSI-based software can be found under the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ . (There are some entries under the Uninstall key for MSI-based packages as well, but not with nearly as much detail as you'll find under the Installer key.)

December 31, 2013 at 11:07 am

Maybe this function will help. It parses the registry keys Dave mentioned.
function Get-InstalledProgram{
< # .SYNOPSIS Gets the installed programs. .DESCRIPTION This function queiries the registry for installed programs. .PARAMETER DisplayName Optional filter. Name of the program. Suports wild cards. .PARAMETER Publisher Optional filter. Name of the appliication vendor. Supports wild cards. .EXAMPLE Get-InstalledPrograms .EXAMPLE Get-InstalledPrograms -Publisher VMware* .EXAMPLE Get-InstalledPrograms | Out-GridView .INPUTS System.String,System.String .OUTPUTS PSOBject .NOTES Created on: 8/10/2013 8:32 PM Created by: David Christian .LINK #>



#region Filter Prep
$WhereFilter = '![System.String]::IsNullOrEmpty($_.DisplayName)'
Write-Verbose -Message "Base Where filter: $WhereFilter"

$WhereFilter = '{0} -and ($_.DisplayName -like "{1}")' -f $WhereFilter,$DisplayName
Write-Verbose -Message "Adding display filter: $WhereFilter"

$WhereFilter = '{0} -and ($_.Publisher -like "{1}")' -f $WhereFilter,$Publisher
Write-Verbose -Message "Adding publisher filter: $WhereFilter"

$whereBlock = [scriptblock]::Create($WhereFilter)
#endregion Filter Prep

#region Uninstall Registy Keys

$UNINSTALL_ROOT = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
$UNINSTALL_WOW = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$UNINSTALL_USER = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
$UNINSTALL_WOWUSER = "HKCU:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"

#endRegion Uninstall Registy Keys

$regPath = @{n='RegistryKey';E={$_.PSPath.Split('::')[-1]}}


foreach ($key in $RegKeys) {
if(Test-Path -Path $key){
Write-Verbose -Message "Reading $key"

$regKeyColumn = @{Name='RegistyKey';Expression={$key}}

Get-ItemProperty -Path $key -Name * -ErrorAction 'Stop'|
Where-Object $whereBlock |
Select-Object -Property DisplayName,
Write-Warning -Message $_.Exception.Message
}#end Catch
}#end foreach key
}#end Get-InstalledProgram

January 3, 2014 at 3:11 pm

Is this the easiest way that one would be able to determine if a program was installed using powershell?

January 3, 2014 at 4:56 pm

Well It looks like with all your help and a little poking around on google, found the solution to my problem

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -eq "Windows Installer PowerShell Module"}

Thanks for everyones help!