How to Export a List of Bundle Relationships in ZCM?

As a ZCM (ZENworks Configuration Management) system administrator, you sometimes need to generate lists of things (and relationships to other things) that may not be possible in the management console.  Of course, one of the most powerful aspects of ZCM is that the command tools allow you to do everything that can be done in the management console, and more.

Sometimes though, you might need a differently formatted output from the command default, or maybe you need to consolidate or aggregate/amalgamate the output of two different commands; what then?  Scripts, that’s what.

I was in just-such a situation the other day when a co-worker asked for some help.  He was building an app-tracking database (outside of ZCM), and needed to get a list of every bundle that is currently in ZCM; and for each, list:

  • the Bundle GUID
  • Bundle/App Name,
  • Bundle/App Folder Path (in the ZCM hierarchy), and
  • any device associations (note that we did not need user associations).

So I searched the ‘Net, and stumbled upon this little gem by Shaun Pond….  (An aside about Shaun:  Shaun has been a diligent and helpful member of the Novell Forums for a very long time, helping more people that he will ever know. Thanks Shaun; a hundred times.) …which was close to what I needed in theory, but did not quite hit it all the way.

So I took Shaun’s script, kicked it around a bit, and ended up with something that generates the output I needed.

In my case, on the project I am on right now, all the ZCM Primary servers are Windows-based, so the script I feature here is a DOS-style batch script.

A couple notes:

  • Please, please, please read it before just pasting it and running it.  There’s no format commands in there or anything, but if you don’t understand what it’s doing, don’t use it!
  • Just paste the contents into a batch file, something like C:\zcmbundles.bat
  • The script will prompt for a Zone Administrator-level credential that will be stored for the duration of the script execution. Without this, it would fail as it tries in vein to prompt for credentials

Without further ado, here is the script:

@echo off
rem Thanks to the always-awesome Shaun Pond for creating
rem the launching point from which I built this script.
rem First we clean up the old files, if any...
if exist c:\bl.txt del c:\bl.txt
echo. > c:\zcmassign.txt
rem Let's prompt for the Zone Administrator credential
set /p userguy= Enter the adminisrator username (probably Administrator):
zman asc %userguy%
rem Now generate the list of bundles
rem Note that I'm excluding Imaging Bundles, Bundle Groups (which has different columns) and any garbage...
zman bl -r --terse|findstr /C:"Windows Bundle" /C:"Directive Bundle" /C:"File Bundle" >c:\bl.txt
rem Lastly we loop through the bundle list and call out the bundle GUID and its relationships...
for /F "tokens=1,4 delims=|" %%f in (c:\bl.txt) do echo Item: %%g/%%f...&echo. >> c:\zcmassign.txt&zman ogg "%%g/%%f" | FindStr [0-9] >> c:\zcmassign.txt&echo %%f >> c:\zcmassign.txt&echo %%g >> c:\zcmassign.txt&zman blas "%%g/%%f" -t device --terse | FindStr "|" >> c:\zcmassign.txt
rem Clear the administrator credential
zman acc
rem Done!
rem Go check zcmassign.txt for your list of assignments.

Of course, you can modify the script to your taste, including or excluding what you want, changing the type to users from device, etc., etc.  But this should get you started…

And don’t worry… I’m going to post the bash/Linux equivalent a little bit down the road, in case you happen to have SLES Primary ZCM servers.



  1. Ido Yavin

    Hi Jeremy,
    A very good article! I am need to ‘clean up’ in our ZCM and trying therefore to export a list of all our bundles relationships so I will have something to work with. I ran though into the same issue regarding the limitations of zman blas… The thing is, we are running zenworks on SLES. I wonder if you maybe have the equivalent script in bash? I have a very little experience in writing shell script and it will help me a lot.

    Best regards,
    Ido Yavin

  2. Jeremy Pavlov

    @Ido –
    I was asked once before about that, but I’ve never gotten around to making a bash equivalent. It could be done of course, but I don’t have much spare time these days, much less a Linux-based Zenworks server to write and test against. But, your voice has been added to the chorus, and just maybe someone else has already done it that can pipe in here…

  3. chihab

    I have the same need as Ido Yavin. I’m running Zenworks on ZLES.
    please help.

  4. Earthling

    Hi there, you’re right about Shaun, he’s great! Would you happen to have the syntax to export the exe path of the bundles, and any parameters?

Leave a Comment

Your email address will not be published. Required fields are marked *