Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- Title: XenServer MCS Fix for XenDesktop 7.12
- Written By: David Ott
- Description: Solution to the problem described here
- "https://discussions.citrix.com/topic/383281-xendesktop-712-mcs-xenserver-pv-network-device-issues/"
- after upgrading to XenDesktop 7.12 and you create MCS desktops in a XenServer environment.
- Special thanks to Paul Browne for posting the solution to the problem!
- The script performs the following:
- 1. Checks for xe.exe, and will prompt you to install XenCenter if it does not detect it where it should be
- 2. Asks for the root password of your XenServer environment
- 3. Asks for the ip or fqdn of your XenServer management interface
- Note: I didn't build any error correction into the XenServer logon process, so if you typed in something wrong in steps 2-3
- nothing will happen.
- 4. Assuming you did things right the script will query your XS environment for all VMs, work some magic to create an
- 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
- which have their "has-vendor-device" value set to "false"
- 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
- 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
- 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
- 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
- 6b. Prints to the screen that it is updating the VM "has-vendor-device" value to true
- 6c. Performs the vm-param-set operation on the VM to change the "has-vendor-device" value to true
- 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
- the value is still false it will completely stop the script so you can investigate the problem (maybe the VM powered on in
- the middle of the script operations).
- #>
- $xe = "c:\program files (x86)\citrix\xencenter\xe.exe"
- if (!(test-path $xe)) {
- $xe = "c:\program files\citrix\xencenter\xe.exe"
- if (!(test-path $xe)) {
- Write-Host "Please install XenCenter before continuing."
- break
- }
- }
- $pass = Read-Host "Enter the root password for your XenServer environment" # password to connect to the pool master
- $master = Read-Host "Enter the ip address or FQDN of the management interface" # ipaddress or hostname of the pool master
- $vms = &$xe vm-list -s $master -u root -pw $pass params=name-label,has-vendor-device | %{
- ($_ -split ": ")[1]
- }
- $vms = $vms | ?{$_ -ne $null}
- $i = 0
- $updates = 0..(($vms | measure).count -1) | %{
- if ($_ % 2) {
- $name = $vms[$_-1]
- $vendor = $vms[$_]
- $i | select @{n='VM';e={$name}},@{n='Vendor_Device';e={$vendor}}
- }
- } | ?{$_.vm -ne "control domain on host" -and $_.vendor_device -eq "false"} | sort vendor_device | ogv -Title "Select VMs to update" -OutputMode Multiple
- foreach ($update in $updates) {
- $namelabel = $update.VM
- $uuid = &$xe vm-list -s $master -u root -pw $pass name-label=$namelabel --minimal
- if ((&$xe vm-list -s $master -u root -pw $pass name-label=$namelabel params=power-state --minimal) -ne "halted") {
- Write-Host "Shutdown $namelabel prior to attempting to update. Skipping $namelabel"
- continue
- }
- Write-Host "Updating $namelabel `"has-vendor-device`" value to true"
- &$xe vm-param-set -s $master -u root -pw $pass uuid=$uuid has-vendor-device=true
- $check = &$xe vm-list -s $master -u root -pw $pass name-label=$namelabel params=has-vendor-device --minimal
- if ($check -eq "true") {
- Write-Host "Update of $namelabel successful" -ForegroundColor Green
- } else {
- Write-Host "Update of $namelabel NOT successful, stopping script!" -ForegroundColor Red
- break
- }
- }
Add Comment
Please, Sign In to add comment