BDD 2007 and PowerShell

I've hinted several times that it is possible to use PowerShell to interact with BDD 2007, basically to perform the same functions via a PowerShell script that you can do by using the Deployment Workbench MMC snap-in.  If you were at MMS 2007, you may have seen a glimpse in a sample script presented in my advanced ZTI session.  Of course now you want to know how you can do it yourself.

First, a little background information.  The Deployment Workbench is an MMC 3.0 snap-in written in C#.  It is a single .NET DLL, Microsoft.BDD.Workbench.dll, loaded automatically by MMC when you select the "Deployment Workbench" shortcut.  It presents the user interface of the snap-in, but it doesn't do the real work.  That's left for another .NET C# component, Microsoft.BDD.ConfigManager.dll (ConfigManager for short) responsible for all data items maintained by BDD 2007.  ConfigManager has no user interface; it is a data layer object, designed solely for interacting with the underlying XML and database data items.

Now technically ConfigManager is not a PowerShell cmdlet; using it is not as simple as using the built-in cmdlets.  But, because PowerShell interacts so easily with .NET components, it is able to make use of all the same objects, methods, and properties that Deployment Workbench uses from ConfigManager.  So, you can build scripts that act exactly like the Deployment Workbench.  To see what all of those objects, methods, and properties are, you can check out the BDD 2007 source code that was released last week, available at

To help you along, here's a brief tutorial.  At the top level of ConfigManager is a "Manager" class used to access all the other classes.  The main classes correspond to the nodes that you see in Deployment Workbench:

  • OSManager
  • BuildManager
  • DriverManager
  • DriverGroupManager
  • ApplicationManager
  • PackageManager
  • DeployManager
  • DatabaseManager

All of these manager classes behave similarly, enabling the enumeration of available items, adding new items, removing existing items, etc.

By this point you're probably saying "enough babble, show me how to do it."  OK, here's a simple example PowerShell script that lists all of the available drivers in a simple data table:

[System.Reflection.Assembly]::LoadFile("C:\Program Files\BDD 2007\bin\Microsoft.BDD.ConfigManager.dll")
$manager = [Microsoft.BDD.ConfigManager.Manager]

Pretty simple.  Now, let's show something a little more interesting.  The following script will look at each driver and place each into a driver group named after the driver's manufacturer:

# Initialization

[System.Reflection.Assembly]::LoadFile("C:\Program Files\BDD 2007\bin\Microsoft.BDD.ConfigManager.dll")
$manager = [Microsoft.BDD.ConfigManager.Manager]

# Process each driver

foreach ($driver in $manager::DriverManager)

# See if the group already exists

$driverGroup = $manager::DriverGroupManager.Find($driver["Manufacturer"])
if ($driverGroup -eq $null)
write-host "Adding driver group for" $driver["Manufacturer"]

$driverGroup = $manager::DriverGroupManager.CreateNew()
$driverGroup["Name"] = $driver["Manufacturer"]


# Make sure the driver is in the group

if (-not $driverGroup.IsMember($driver["guid"]))
write-host "Adding driver" $driver["guid"]


Hopefully this is enough to get you thinking about the possibilities.  It's certainly not a complete tutorial, but give it a try!  (If you get stuck, drop me an e-mail or post a comment.  I'd be happy to provide more simple samples, but need you to tell me what might be useful.)

A warning before wrapping up:  Think of the PowerShell session as another Deployment Workbench operating against the same configuration.  Running two Deployment Workbenches at the same time can have some interesting results, with one overwriting changes made from the other.  The same can happen between a PowerShell session and a Deployment Workbench, so be careful.

Comments (4)
  1. Anonymous says:

    BDD 2007 has a great technique of determining which drivers should be applied to the clients being deployed.

  2. Anonymous says:

    Michael Niehaus (l’architecte de la solution BDD) a publié récemment un blog sur l’interaction entre

  3. Anonymous says:

    I’ve been trying to use some of the posted scripts to do bulk driver group configs, but with no luck.

    I’ve tried Ben Hunters script:

    It’s doing every part perfectly, but the group management.  I can point the script at the top level of my driver repository and all the drivers are pulled in, and the script says it’s adding them to the group…but when I open the BDD Workbench and view the drivers they are not members of the group (other than all drivers)

    Any suggestions on how to debug what I’m doing wrong, or to add some additional output would be great.



Comments are closed.

Skip to main content