This script provides my PowerShell translation of C# code created by the authors of Microsoft SQL Server 2008 Analysis Services Unleashed.  I have tested this code on 64-bit Windows 7 running SQL Server 2008 R2 with Analysis Services, and the Windows PowerShell version 2 IDE (Integrated Development Environment).  This code requires the sample “Food Mart 2008” database available from the authors’ website at

I shared this code as part of my data mining blog.  I have been reviewing this book, and I made comments on this code at

Gorbach, I., Berger, A., & Melomed, E. (2009). Microsoft SQL Server 2008 Analysis Services Unleashed. Indianapolis, IN: Pearson Education Inc.

# 3305_AdomdDimensionOrdinal.ps1
# Mark Tabladillo
# Last Updated: July 22, 2010
# Program Created: July 22, 2010


# Connect to the server
$con = new-object Microsoft.AnalysisServices.AdomdClient.AdomdConnection
$con.ConnectionString = "Datasource=localhost; Initial Catalog=FoodMart 2008;"

$cube  = $con.cubes["Warehouse and Sales"]

# Iterate over the dimensions collection
foreach ($dim in $cube.Dimensions) 
	write-host "Dimension: '" $dim.Name "' Ordinal= " $dim.Properties["DIMENSION_ORDINAL"].Value.ToString()