david62277

XenServer_XenDesktop_7.12_Issue_Fix

Feb 9th, 2017
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. Title: XenServer MCS Fix for XenDesktop 7.12
  3. Written By: David Ott
  4.  
  5. Description: Solution to the problem described here
  6. "https://discussions.citrix.com/topic/383281-xendesktop-712-mcs-xenserver-pv-network-device-issues/"
  7. after upgrading to XenDesktop 7.12 and you create MCS desktops in a XenServer environment.
  8. Special thanks to Paul Browne for posting the solution to the problem!
  9.  
  10. The script performs the following:
  11. 1.  Checks for xe.exe, and will prompt you to install XenCenter if it does not detect it where it should be
  12. 2.  Asks for the root password of your XenServer environment
  13. 3.  Asks for the ip or fqdn of your XenServer management interface
  14. Note: I didn't build any error correction into the XenServer logon process, so if you typed in something wrong in steps 2-3
  15. nothing will happen.
  16. 4.  Assuming you did things right the script will query your XS environment for all VMs, work some magic to create an
  17. array we can use, and output that array to out-gridview for you to select the VMs you wish to fix.  It will only display VMs
  18. which have their "has-vendor-device" value set to "false"
  19. Note: if you are unsure about anything at this point hit "Cancel" or X out of the out-gridview window, and the script will end
  20. 5. Select the VM(s) you wish to fix in the out-gridview window (hold ctrl or shift to select multiple VMs), and then hit OK
  21. 6. Using the VM(s) you selected the script will then do a foreach loop that will get the uuid of the VM to update
  22. 6a.  Checks to see if the VM is in a halted state - if not it will skip the VM, else it will continue to update
  23. 6b.  Prints to the screen that it is updating the VM "has-vendor-device" value to true
  24. 6c.  Performs the vm-param-set operation on the VM to change the "has-vendor-device" value to true
  25. 6d.  Checks to see if the value has been updated.  If so it will move on to the next VM (if you selected multiple), and if
  26. the value is still false it will completely stop the script so you can investigate the problem (maybe the VM powered on in
  27. the middle of the script operations).
  28. #>
  29.  
  30. $xe = "c:\program files (x86)\citrix\xencenter\xe.exe"
  31. if (!(test-path $xe)) {
  32. $xe = "c:\program files\citrix\xencenter\xe.exe"
  33. if (!(test-path $xe)) {
  34. Write-Host "Please install XenCenter before continuing."
  35. break
  36. }
  37. }
  38. $pass = Read-Host "Enter the root password for your XenServer environment" # password to connect to the pool master
  39. $master = Read-Host "Enter the ip address or FQDN of the management interface" # ipaddress or hostname of the pool master
  40. $vms = &$xe vm-list -s $master -u root -pw $pass params=name-label,has-vendor-device | %{
  41. ($_ -split ": ")[1]
  42. }
  43. $vms = $vms | ?{$_ -ne $null}
  44. $i = 0
  45. $updates = 0..(($vms | measure).count -1) | %{
  46. if ($_ % 2) {
  47. $name = $vms[$_-1]
  48. $vendor = $vms[$_]
  49. $i | select @{n='VM';e={$name}},@{n='Vendor_Device';e={$vendor}}
  50. }
  51. } | ?{$_.vm -ne "control domain on host" -and $_.vendor_device -eq "false"} | sort vendor_device | ogv -Title "Select VMs to update" -OutputMode Multiple
  52. foreach ($update in $updates) {
  53.  
  54. $namelabel = $update.VM
  55. $uuid = &$xe vm-list -s $master -u root -pw $pass name-label=$namelabel --minimal
  56. if ((&$xe vm-list -s $master -u root -pw $pass name-label=$namelabel params=power-state --minimal) -ne "halted") {
  57. Write-Host "Shutdown $namelabel prior to attempting to update.  Skipping $namelabel"
  58. continue
  59. }
  60. Write-Host "Updating $namelabel `"has-vendor-device`" value to true"
  61. &$xe vm-param-set -s $master -u root -pw $pass uuid=$uuid has-vendor-device=true
  62. $check = &$xe vm-list -s $master -u root -pw $pass name-label=$namelabel params=has-vendor-device --minimal
  63. if ($check -eq "true") {
  64. Write-Host "Update of $namelabel successful" -ForegroundColor Green
  65. } else {
  66. Write-Host "Update of $namelabel NOT successful, stopping script!" -ForegroundColor Red
  67. break
  68. }
  69. }
Add Comment
Please, Sign In to add comment