{"id":797,"date":"2011-05-16T11:45:38","date_gmt":"2011-05-16T16:45:38","guid":{"rendered":"http:\/\/yourLinuxGuy.com\/?p=797"},"modified":"2011-05-20T15:27:21","modified_gmt":"2011-05-20T20:27:21","slug":"how-to-export-a-list-of-bundle-relationships-in-zcm","status":"publish","type":"post","link":"https:\/\/yourLinuxGuy.com\/?p=797","title":{"rendered":"How to Export a List of Bundle Relationships in ZCM?"},"content":{"rendered":"<p>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.\u00a0 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.<\/p>\n<p>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?\u00a0 Scripts, that&#8217;s what.<\/p>\n<p>I was in just-such a situation the other day when a co-worker asked for some help.\u00a0 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:<\/p>\n<ul>\n<li>the <strong>Bundle GUID<\/strong>,\u00a0<strong> <\/strong><\/li>\n<li><strong>Bundle\/App Name<\/strong>,<\/li>\n<li><strong>Bundle\/App Folder Path<\/strong> (in the ZCM hierarchy), and<\/li>\n<li><strong>any <em>device<\/em> associations<\/strong> (note that we did not need <em>user<\/em> associations).<\/li>\n<\/ul>\n<p>So I searched the &#8216;Net, and stumbled upon <a title=\"http:\/\/forums.novell.com\/novell-product-support-forums\/zenworks\/configuration-management\/zcm-bundles\/420026-export-bunle-assignements.html\" href=\"http:\/\/forums.novell.com\/novell-product-support-forums\/zenworks\/configuration-management\/zcm-bundles\/420026-export-bunle-assignements.html\" target=\"_blank\">this little gem by Shaun Pond<\/a>&#8230;.\u00a0<em> (An aside about Shaun:\u00a0 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.)<\/em> &#8230;which was close to what I needed in theory, but did not quite hit it all the way.<\/p>\n<p>So I took Shaun&#8217;s script, kicked it around a bit, and ended up with something that generates the output I needed.<\/p>\n<p>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.<\/p>\n<p>A couple notes:<\/p>\n<ul>\n<li>Please, please, please read it before just pasting it and running it.\u00a0 There&#8217;s no format commands in there or anything, but if you don&#8217;t understand what it&#8217;s doing, don&#8217;t use it!<\/li>\n<li>Just paste the contents into a batch file, something like C:\\zcmbundles.bat<\/li>\n<li>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<\/li>\n<\/ul>\n<p>Without further ado, here is the script:<\/p>\n<p><code> <\/code><\/p>\n<pre><code>@echo off\r\nrem\r\nrem Thanks to the always-awesome Shaun Pond for creating\r\nrem the launching point from which I built this script.\r\nrem http:\/\/forums.novell.com\/novell-product-support-forums\/zenworks\/configuration-management\/zcm-bundles\/420026-export-bunle-assignements.html\r\nrem\r\nrem First we clean up the old files, if any...\r\nif exist c:\\bl.txt del c:\\bl.txt\r\necho. &gt; c:\\zcmassign.txt\r\nrem\r\nrem Let's prompt for the Zone Administrator credential\r\nset \/p userguy= Enter the adminisrator username (probably Administrator):\r\nzman asc %userguy%\r\nrem\r\nrem Now generate the list of bundles\r\nrem Note that I'm excluding Imaging Bundles, Bundle Groups (which has different columns) and any garbage...\r\nzman bl -r --terse|findstr \/C:\"Windows Bundle\" \/C:\"Directive Bundle\" \/C:\"File Bundle\" &gt;c:\\bl.txt\r\nrem\r\nrem Lastly we loop through the bundle list and call out the bundle GUID and its relationships...\r\nfor \/F \"tokens=1,4 delims=|\" %%f in (c:\\bl.txt) do echo Item: %%g\/%%f...&amp;echo. &gt;&gt; c:\\zcmassign.txt&amp;zman ogg \"%%g\/%%f\" | FindStr [0-9] &gt;&gt; c:\\zcmassign.txt&amp;echo %%f &gt;&gt; c:\\zcmassign.txt&amp;echo %%g &gt;&gt; c:\\zcmassign.txt&amp;zman blas \"%%g\/%%f\" -t device --terse | FindStr \"|\" &gt;&gt; c:\\zcmassign.txt\r\nrem\r\nrem Clear the administrator credential\r\nzman acc\r\nrem\r\nrem Done!\r\nrem Go check zcmassign.txt for your list of assignments.<\/code><\/pre>\n<p><code> <\/code><\/p>\n<p>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.\u00a0 But this should get you started&#8230;<\/p>\n<p>And don&#8217;t worry&#8230;  I&#8217;m going to post the bash\/Linux equivalent a little bit down the road, in case you happen to have SLES Primary ZCM servers.<\/p>\n<p>\ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.\u00a0 Of course, one of the most powerful aspects of ZCM&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/yourLinuxGuy.com\/?p=797\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[11,20,53,100],"tags":[],"class_list":["post-797","post","type-post","status-publish","format-standard","hentry","category-intermediate","category-windowsgeneral","category-zcm10","category-zcm11"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnjn1-cR","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=797"}],"version-history":[{"count":12,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/797\/revisions"}],"predecessor-version":[{"id":810,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=\/wp\/v2\/posts\/797\/revisions\/810"}],"wp:attachment":[{"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yourLinuxGuy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}