Tagged: COM+

Read MSI information with PowerShell

I tried to search for some way to read MSI-information with PowerShell, that wasn’t to easy to find.

Anyway, here is a function that helps you read the “Property” view from one MSI-file, the result is stored in a hash table.

# Load some TypeData
$SavedEA = $Global:ErrorActionPreference
$Global:ErrorActionPreference = "SilentlyContinue"
Update-TypeData -AppendPath ((Split-Path -Parent $MyInvocation.MyCommand.Path) + "\comObject.types.ps1xml")
$Global:ErrorActionPreference = $SavedEA

function global:get-msiproperties {
		[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="MSI Database Filename",ValueFromPipeline=$true)]

	# A quick check to see if the file exist
	if(!(Test-Path $msiDbName)){
		throw "Could not find " + $msiDbName

	# Create an empty hashtable to store properties in
	$msiProps = @{}
	# Creating WI object and load MSI database
	$wiObject = New-Object -com WindowsInstaller.Installer
	$wiDatabase = $wiObject.InvokeMethod("OpenDatabase", (Resolve-Path $msiDbName).Path, 0)
	# Open the Property-view
	$view = $wiDatabase.InvokeMethod("OpenView", "SELECT * FROM Property")
	# Loop thru the table
	$r = $view.InvokeMethod("Fetch")
	while($r -ne $null) {
		# Add property and value to hash table
		$msiProps[$r.InvokeParamProperty("StringData",1)] = $r.InvokeParamProperty("StringData",2)
		# Fetch the next row
		$r = $view.InvokeMethod("Fetch")

	# Return the hash table
	return $msiProps

You need to expand your type configuration with this file, saved as comObject.types.ps1xml in the same directory as the script above.

Copy from: Abhishek's PowerShell Blog - http://abhishek225.spaces.live.com/blog/

Original post: http://abhishek225.spaces.live.com/blog/cns!13469C7B7CE6E911!165.entry
					$type = $this.gettype();
					$type = $this.gettype();
					$type = $this.gettype();
					$index = $args.count -1 ;
					$type = $this.gettype();
					$index = $args.count -1 ;

Monitor COM+ Call Time

With a little help from Egilh you can monitor the Call Time on your COM-objects in MOM…

First, download and install the DLL on the server you want to monitor, then use this script:

' Script to montior COM-obecjt call time
'                                         Rikard Rönnkvist / snowland.se / 2008-09-16

'Get the com+ call times
Set oTracker = CreateObject("egilh.ComTracker")
sResult = oTracker.getStatistics()
'Display call times
Set oDOM = CreateObject("MSXML2.DomDocument.3.0")
oDOM.loadXML (sResult)

For Each oNode In oDOM.selectNodes("/applications/application/classes/class")
	' Create performance data
	Set oPerfData = ScriptContext.CreatePerfData
	With oPerfData
		.ObjectName = "COM-Objects"
		.InstanceName = oNode.selectSingleNode("progID").Text
		.CounterName = "CallTime"
		.Value = oNode.selectSingleNode("responseTime").Text
	End With
	ScriptContext.Submit oPerfData
	Set oPerfData = Nothing