Preston Gallwas

Aug 062014

Post credit goes to David62277, a community contributor from #Citrix IRC on Freenode In order to update certain software on a PVS image (hosting platform tools, pvs target device software, etc) it is required to “reverse image” your vdisk back to a normal VM, install your update, and image back to vdisk. This is because the machine is actually booted to network (it is getting its C: drive from a network share essentially), and if you disrupt that connection while the vdisk is in private mode it can (most likely will) ruin your vdisk image. The process of reverse imaging, and re-imaging your vdisk can be very time consuming. There is a better way… update your vDisk without having to reverse image by directly booting to a .VHD from Windows PE.

You will need the Microsoft Windows AIK (I’m using Windows 7 version)


  1. Download and install the Microsoft Windows AIK and install it on your workstation
    1. This is what we will use to create a bootable .iso image
  2. Once installed create your .iso
    1. Start => All Programs => Microsoft Windows AIK => Deployment Tools Command Prompt1-BootVHDwithPE
    2. Run “copype.cmd amd64 c:\winpe” (note: you can use x86 or ia64 depending on your architecture… don’t think it matters though. Also, you can specify a different directory).2-BootVHDwithPE.png
    3. Now we want to add boot support
      1. Imagex /apply c:\winpe\winpe.wim 1 c:\winpe\mount
      2. Copy c:\winpe\iso\bootmgr c:\winpe\mount
      3. Mkdir c:\winpe\mount\boot3-BootVHDwithPE.png
    4. Run the following commands:
      1. Bcdedit /createstore c:\winpe\mount\boot\BCD
      2. Bcdedit /store c:\winpe\mount\boot\BCD -create {bootmgr} /d “Boot Manager”
      3. Bcdedit /store c:\winpe\mount\boot\BCD -set {bootmgr} device boot
      4. Bcdedit /store c:\winpe\mount\boot\BCD -create /d “WINPE” -application osloader4-BootVHDwithPE
    5. Run the following commands using the guid you received from the last command
      1. Bcdedit /store c:\winpe\mount\boot\BCD -set <GUID> osdevice boot
      2. Bcdedit /store c:\winpe\mount\boot\BCD -set <GUID> device boot
      3. Bcdedit /store c:\winpe\mount\boot\BCD -set <GUID> path \windows\system32\winload.exe
      4. Bcdedit /store c:\winpe\mount\boot\BCD -set <GUID> systemroot \windows
      5. Bcdedit /store c:\winpe\mount\boot\BCD -set <GUID> winpe yes
      6. Bcdedit /store c:\winpe\mount\boot\BCD -set <GUID> detecthal yes
      7. Bcdedit /store c:\winpe\mount\boot\BCD -displayorder <GUID> -addlast5-BootVHDwithPE
    6. One last command
      1. Oscdimg -n -m -o -bc:\winpe\ c:\winpe\mount c:\winpe\bootdisk.iso6-BootVHDwithPE
    7. Done with the “hard” part
  3. Copy the .iso file to your ISO storage repository (xenserver, vmware, whatever)
  4. Create a new disk in your hypervisor that is about 2x as large as the size of your vdisk (note: use the size it shows in the PVS console x 2) – this gives you room to play.
  5. Attach that disk to your PVS server
    1. Create a partition, format, etc.
  6. Merge your vdisk to a new merged base (set it as test)7-BootVHDwithPE
  7. Copy the merged .vhd file to the new drive you just attached to the PVS server
  8. Detach the new drive from the pvs server, and attach it to the VM you normally use to update your image (should be the only drive attached), or a VM that matches the virtual hardware of your target devices.
    1. If the vm is a target device in PVS set it to boot from hard disk not vdisk
  9. If using Xenserver set the VM to boot from CD, if using vmware edit settings of the vm to boot into bios so you can change the boot order so CD is first.
  10. Boot the VM and you should see this screen8-BootVHDwithPE
  11. Run the following commands
    1. Diskpart
    2. List disk
      1. Should see disk 0 and only9-BootVHDwithPE
    3. Select disk 0
    4. Select part 1
    5. Active
      1. This makes partition 1 on disk 0 bootable10-BootVHDwithPE
    6. exit
    7. Now I want to rename the .vhd file on disk 0 (C:\), so I can use it over and over again (NOTE: this is CASE SENSITIVE)
    8. C:
    9. Dir
      1. Just so I can see the file name
    10. Ren win8.8.vhd temp.vhd (or whatever you want to name it. NOTE: this is CASE SENSITIVE)11-BootVHDwithPE
    11. X:
    12. Diskpart
    13. Select vdisk file=c:\temp.vhd
    14. Attach vdisk
    15. List vol
  12. Now I can see my vhd is mounted as volume D (yours may be different, but make note of it)
  13. A couple more commands
    1. Exit (to exit diskpart)
    2. Bcdboot d:\windows /s c:
      1. Use whatever volume letter you have for your vdisk13-BootVHDwithPE
    3. Exit
      1. System should now reboot and boot into your vhd (just remember not to hit any key, or just eject the cd image from the vm)
  14. Make the changes that normally would require you to reverse image, and shut down.
  15. Detach the drive from the editing VM and re-attach it to your PVS server.
  16. Copy the .vhd back to the store
  17. Detach the drive (keep it around for next time)
  18. Rename the original vhd (win8.8.vhd for me) to .old, and rename the temp.vhd to whatever the original name was. (NOTE: this is CASE SENSITIVE)
  19. Boot your test devices and make sure everything is working
  20. Once satisfied, shutdown the test devices, delete the .old file, and promote the vdisk to production
  21. Switch the editing VM back to booting from network for when you have your normal updates

From here on out these kinds of edits should be easy.

  1. Attach the virtual disk to pvs
  2. Remove the old temp.vhd file (assuming you didn’t before)
  3. Copy the vhd you wish to edit to it
  4. Rename it to temp.vhd (or whatever you named it to begin with)
  5. Detach the drive from PVS
  6. Change your editing vm target device in PVS to boot to hard drive
  7. Attach the drive to your editing vm
  8. Boot it
  9. Follow steps 14-20 above
Apr 042014

Often when troubleshooting an issue a need arises to collect logs from multiple machines.  This is easily achieved when the number of machines is small, or known – a few servers or desktops here or there – but when it comes to analyzing logs for a large pooled-random group of desktops or several hundred computers in your organization, grabbing the files can be a pain.  Using the magic of Powershell, you can easily collect logs from as many computers as you desire in a matter of minutes.

Add-PSSnapin Citrix*
$DeliveryController = "citrixdc.contoso.local"
$vmCollection = Get-BrokerDesktop -PowerState On -AdminAddress $DeliveryController -MaxRecordCount 9999
# you can replace or repeat this with any collection you want (i.e. get-adcomputer).

foreach($hostedDesktop in $vmCollection)
$vm = $_.DNSName
if(Test-Connection -Cn $vm -BufferSize 16 -Count 1 -ea 0 -quiet)
Write-Host "$vm is online, collecting logs"
$path="\\$vm\d$\" #Use your log location. In this case, logs are co-located logs on the write cache D: drive.
dir -Path $path -recurse -include "*.evtx","*.log" -Exclude "*vdiskcache","pagefile.sys" | %{ # Critera shown for example. If you include all, be sure you exclude vdiskcache and pagefile.sys
$destPath="$destbasePath\$vm" # The full destination path
if(!(test-path $destPath)) { mkdir $destPath } #make new folders for each VM you collect from
copy $_.pspath $destPath #Make the magic happen

Sep 252012

#Citrix aka CitrixIRC

  in Citrix irc support by Atum

Perhaps the best resource (or at least the most fun for me!) has been working with the people in #Citrix (on IRC, not twitter!) on  If you don’t know about IRC, perhaps you’re ultra young or you lived under a rock, but Wikipedia can help you out.  I invite all readers to join and check out what we have to offer.  There are a number of ways to get connected.

Getting Connected


Webchat is available and is available to anyone with a browser by visiting  Webchat offers the ability to authenticate and pre-join a channel, which can be helpful, but if you’re a frequent visitor you might want to check out some IRC clients.  Once you’ve navigated to the webchat page, simply fill in a username, for the channel type #Citrix click connect and you’ll be ready to chat.

IRC Client

My preferred client at the moment is ChatZilla, which is available either as a Firefox add-on or through a launcher called XULRunner.  ChatZilla has been around a long time and is very mature.  It includes robust view support, logging, BNC connections and a healthy scripting engine.  Other popular options include IRSSI, mIRC (shareware, but perhaps the most used client IRC client of all time), xChat (trialware for Windows), and IceChat.


If you prefer using Slack, head over to the CitrixIRC Slack page to register as a user of the CitrixIRC Slack Team.  Slack is a collaboration platform that has become popular in recent years and has excellent client support on multiple platforms, including PC, Mac, Web and Mobile.  Slack supports a variety notifications.  The integration with IRC is completed via a “bot” that relays all text from IRC to Slack and back.  If you are in IRC, you will see <WoEUC> Username “text”.

Getting Help

Remember, we all work (in one form or another I’m sure!) so people aren’t always watching chat.  When you join, remember to state your product (including version if you can) and question.  There is no need to ask for permission to ask your question.  If no one replies right away, stick around and see if someone can help.  It may not be instant support, but it can beat spamming F5 on the forums.

Becoming a Regular

So you’ve joined and #Citrix a few times and decided it is a helpful resource.  Perhaps your next step is to become a regular!  Check out the website for additional tips on getting started.You can also check out the CitrixIRC website! Hope to see you there!