PowerShell to Delete only Rule BLBs

Post Reply
User avatar
paulsimon
MVP
Posts: 808
Joined: Sat Sep 03, 2011 11:10 pm
OLAP Product: TM1
Version: PA 2.0.5
Excel Version: 2016
Contact:

PowerShell to Delete only Rule BLBs

Post by paulsimon »

Hi

I wanted something that would delete Rule BLB files before copying in new Rules.

For those of you that don't know the issue, with a Rule there is a .RUX file and a related .BLB file. In theory the BLB is the formatted version of the .RUX. In reality it contains the same text as the .RUX. An issue can arise where a junior developer doesn't know this and copies in just the RUX. If someone subsequently opens the Rule Editor, TM1 reads the text from the BLB and if this is then saved it can overwrite any changes that had been made in the copied RUX file that was copied in.

A way to avoid this is to use a Promotion Batch file to copy in changes that deletes .BLBs before copying in new files.

However, BLBs are used for two purposes. They provide the formatted version of a rule, and also formatting information for a view.

I wanted something that would delete only the Rule BLBs.

A way to tell the difference is that a Rule BLB will only have one dot, eg MyCube.blb whereas a View BLB will have more than one eg MyCube.Default.blb.

The following PowerShell script deletes just the Rule BLBs (Possibly not the best PowerShell script you have ever seen but it works)

# This deletes Rule BLB files but leaves View BLB files alone

$RuleBLBs = get-childitem <Cube Folder>\*.blb | Where-object {$_.BaseName -notmatch "(\w\.\w)" }
IF( $RuleBLBs -ne $null )
{
foreach( $RuleBLB in $RuleBLBs)
{
Write-Host $RuleBLBs.Name
remove-item $RuleBLB
}
}

To call it from a Batch file use

powershell.exe -executionpolicy remotesigned -file "<Path to Batch Files>\DeleteRuleBLBs.ps1"

Replace <Cube Folder> and <Path to Batch Files> with the appropriate values for your installation.

Regards

Paul Simon
Post Reply