Anders Vikenes

RES Powerfuse 8 Database and Powershell

by on May.01, 2010, under Tech

I needed to enumerate some applications and their settings from RES Powerfuse. My first thought was to just query the mssql-database. I found that it shouldn’t be that easy. Here’s what I discovered and how to retrieve the information trough Powershell. Should be easy to port to .Net if needed.

First a little warning: RES Support doesn’t recommend anyone to touch the database, however in my opinion, as long as you don’t change anything there is no harm. The code and tips in this article doesn’t change anything in the database, but i recommend using a read-only user when connecting to the database in case you change anything in the scripts.

Configuration is stored as XML with unicode in columns of image datatype in MSSQL. If you open the tables in SQL Server Management Studio, you will see the values as truncated HEX.

In my case I was looking for applications and their configuration. This is stored in table tblObjects, and the configuration (and icons) are a column called imgConfig. Similar in table tblAudits you have imgOldConfig and imgNewConfig for each config-change.

1. Connect to the sqlserver and the database for powerfuse (again, use a read-only account for this).

2. Fetch rows from tblObjects (SELECT * FROM tblObjects).

3. Use the function PowerfuseImagedataToXml for parsing the imgConfig and get xml document in return.

Powerfuse.ps1:

# Converts PowerFuse image-config to xml
function PowerfuseImagedataToXml($str)
{
	[byte[]] $bytes = [System.Text.Encoding]::Convert([System.Text.Encoding]::Unicode,[System.Text.Encoding]::ASCII,$str);
	$enc = New-Object System.Text.ASCIIEncoding;
	# Write $enc.GetString($bytes); # uncomment to dump raw xml
	[xml]$xml = $enc.GetString($bytes);
	$xml;
}

$conn = .\sqlConnect.ps1 "myserver" "myuser" "mypass" "mypowerfusedatabase"
if ($conn.state -eq 1)
{
	$data = .\sqlCommand.ps1 $conn "SELECT TOP 10 strDescription, imgConfig FROM tblObjects";
	$rows = $data.Tables[0].Rows
	foreach ($row in $rows)
	{
		[xml] $app = PowerfuseImagedataToXml $row.imgConfig;
		if ($app.application)
		{
			$app.application.configuration.title.ToString();
			$app.application.configuration.commandline.ToString();
			$app.application.configuration.parameters.ToString();
		}
	}
}
else
{
	Write "Connection failed"
}

sqlConnect.ps1 and sqlCommand.ps1 will not be covered in this article. Basically they connect and execute sql command.

I’m gonna look deeper into the database-details so maybe there will be updates to this post later. In the meantime feel free to use the script and/or info as you like.

:,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...