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 rem Thanks to the always-awesome Shaun Pond for creating rem the launching point from which I built this script. rem http://forums.novell.com/novell-product-support-forums/zenworks/configuration-management/zcm-bundles/420026-export-bunle-assignements.html rem rem First we clean up the old files, if any... if exist c:\bl.txt del c:\bl.txt echo. > c:\zcmassign.txt rem rem Let's prompt for the Zone Administrator credential set /p userguy= Enter the adminisrator username (probably Administrator): zman asc %userguy% rem 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 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 rem Clear the administrator credential zman acc rem 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.