Script -- Add New Devices to PVS

Ever been in that situation where you just created 50 new VMs (XenServer, ESXi, Hyper-V, or otherwise) and you needed to add them all to a Device Collection in Citrix Provisioning Services? I have, it's not fun if you have to do them one-by-one. Luckily, Citrix has a magical tool called 'MCLI.exe' which can be found on your PVS hosts.

To add a new device to a collection in PVS, it generally invloves inputing the name for the device, the MAC address and possibly another setting or two. A simple task, but there is no batch add from the GUI. Using MCLI.exe, however, you can script the add process which makes things so much easier. When I create new devices in XenServer that will be used in PVS (for XenDesktop 5.6, in my current scenario), I use Excel to track the name and MAC address once a device is created. Column A is empty, column B contains the device name (NetBIOS name), column C is empty, column D contains the MAC address, and column E is empty.
Once I have my full list generated, I will copy the following to column A:

MCLI.exe add Device -r deviceName="

and in column C I copy this:

" deviceMac="

and in column E I copy this:

" collectionName="<Name of my collection>" siteName="<Name of my PVS site>"

I then copy and paste out all these commands from Excel into notepad, and save it as a bat file which I run on my PVS servers. A single full command will looking something like:

MCLI.exe add Device =r deviceName="XDWIN7001" deviceMac="42:e7:aa:fb:b0:15" collectionName="_Win7 to Deploy" sitename="Production"

Super easy, and it works well. If you are feeling creative, throw in some variable and store the list of MAC addresses and device names in a separate text file and do it that way, which is what I would do if I encounted this scenario more often.

Let me know what you think!

Related Posts

Share on: Twitter | Facebook | Google+ | Email

comments powered by Disqus