Monday, October 14, 2013

Reload a VMs Configuration file in ESXi while the VM is still running

Here is a nice little CLi command that you can use to reload the configuration file of a VM into the ESXi hypervisor while the VM is running.

  1. SSH to the host and determine the VMID for the affected virtual machine using the command:

    vim-cmd vmsvc/getallvms | grep -i VMNAME
  2. Use the VMID from the command in step 1 to reload the configuration on the host by running the command:

    vim-cmd vmsvc/reload VMID

Wednesday, July 24, 2013

PCoIP Session Timoeout on Zero Clients

So I have started setting up Wyse P25 Zero-clients in kiosk mode, I left the Single-Sign-on option turned off to allow any user to login to the VDI.

Shortly after setting up my first 10 my View Connection Broker started filling up with Warnings similar to:

" The pending session on machine X for user Y has expired "

Turns out there is a default PCoIP session ticket timeout of 15 minutes. The following registry key can be added to the virtual desktop to modify the timeout limit.

Browse to the following registry hive:

HKLM\SOFTWARE\VMware, Inc.\VMware VMD\Agent\Configuration

Add a new DWORD entry called "VdmConnectionTicketTimeout"

Setting a Value of 8000 will mean the timeout is approx. 24 hours. (adjust as you need)

VMware View Agent Installation fails

If you are perfoming an upgrade or uninstall of the VMware View Agent on a VM and the installer fails with the message that the install was interrupted you can correct this problem by going into the services on teh VM and setting the VMware View Agent and VMware View Guest Composer services to "disbaled" then rebooting.

Restart your install or uninstall and the problem will should be gone.

Monday, November 26, 2012

Kill a VM (The HARD way)!!

Use this method only after you have tried every other method.

If you have a VM that will not power off or reboot first attempt all of the following methods to shutdown the VM:

  • Shutdown in vCenter
  • Connect vCenter client to host and shutdown
  • Perform a Stop-VM command in Powershell
    • Stop-VM -VM -Kill -Confirm:$false


If after all of these methods fail you can still power down a VM by killing the WorldID on the ESXi hosts

1.  SSH into the host
2. Get a list of all running VMs

  • esxcli vm process list

3. Once you have found your VM document is World ID
4. Issue the following command to kill the VM

  • esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber
    • This command may require the --type=hard option to be successful.

Wednesday, November 14, 2012

Remove an inactive datastore from the vCenter Server inventory



This issue may occur if the datastore was removed from the ESX host before removing it from the vCenter Server Inventory.

To resolve this issue, you must manually remove the datastore references from the vCenter Server Inventory.

To manually remove the datastore references from the Inventory:

Notes:
  • Back up the database before proceeding.
  • Ensure that the datastore is not referenced by any virtual machine.
  1. Stop the VMware VirtualCenter Server service on the vCenter Server. 
  2. Launch SQL Management studio connected to the vCenter Server database.
  3. Run this query to identify the datastore ID in the vCenter Server database:

    select ID from VPX_ENTITY where name ='';
    Where  is the datastore to be removed. The query returns the ID of the datastore.
  4. To remove the datastore from the vCenter Server database:

    1. Run these queries to delete the datastore from the VPX_DS_ASSIGNMENT and VPX_DATASTORE tables:

      delete from VPX_DS_ASSIGNMENT where DS_ID=;
      delete from VPX_VM_DS_SPACE where DS_ID=;
      delete from VPX_DATASTORE where ID=;
      Where  is the output of Step 3.
    2. Run this query to delete the datastore from the entity table:

      delete from VPX_ENTITY where ID=;
  5. Run these queries to verify if the datastore has been removed from the VPX_ENTITYVPX_DS_ASSIGNMENT, andVPX_DATASTORE tables:

    Note: If the datastore references are successfully removed, these queries do not display any results.

    select * from VPX_DS_ASSIGNMENT where DS_ID=;
    select * from VPX_VM_DS_SPACE where DS_ID=;
    select * from VPX_DATASTORE where ID=;
    select * from VPX_ENTITY where ID=;
  6. For the database changes to take effect, restart the VMware VirtualCenter Server service on the vCenter Server.

Wednesday, August 22, 2012

Failed to remove VM: null Fix


When you perform a restore of a vCenter server that supports a VDI environment, you may encounter an issue where you start getting desktops showing up as “Error: Failed to delete VM: null”.  Here are the procedures to correct this problem

1. First disable provisioning on the VDI pool
a. Open View Administrator
b. Click on the pool with the problem
c. Click on the “Status” button
d. Select “Disable Provisioning”

2. Delete all desktops from the pool
a. Click on the “Inventory” tab
b. Shift + Click the first and last desktops
c. Click the “Remove” button

3. Wait till View has a chance to process the deletions (about 5 min)

4. After the 5 min. go into vCenter and manually delete any VMs that may have not gotten deleted. (Do not delete the template VM)

5. Go into ADUC and delete any computer objects that may not have been removed. (Do not delete the template VM computer object)

6. RDP into the View Connection Broker server and follow the instructions on this VMware KB article link to remove any orphaned objects from the ADAM DB on the Connection Broker.
______________________________________________________________________________
Removing the virtual machine from the ADAM database
Note: Before removing entries from the ADAM database, note the virtual machine name of the desktops that are being removed for reference when editing the Composer Database.

1. Connect to the View ADAM Database. For more information, see Connecting to the View ADAM Database (2012377).

2. Locate the GUID of the virtual machine.

To locate the GUID of the virtual machine:

a. Right-click the Connection View ADAM Database [localhost:389], and click New > Query.
b. Under Root of Search, click Browse.. and select the Servers organizational unit.
c. Click OK.
d. In the Query String, paste this search string:

(&(objectClass=pae-VM)(pae-displayname=VirtualMachineName))

Where VirtualMachineName is the name of the virtual machine for which you are trying to locate the GUID. You may use * or ? as wildcards to match multiple desktops.

e. Click OK to create the query.
f. Click the query in the left pane. The virtual machines that match the search are be displayed in the right pane.

3. Record the GUID in cn=
______________________________________________________________________________
Delete the pae-VM object from the ADAM database:

1. Locate the OU=SERVERS container.

2. Locate the corresponding virtual machine's GUID (from above) in the list which can be sorted in ascending or descending order, choose Properties and check the pae-DisplayName Attribute to verify the corresponding linked clone virtual machine object.

3. Delete the pae-VM object.

Notes:
Check if there are entries under OU=Desktops and OU=Applications in the ADAM database.
A broken pool that does not contain any desktops can be removed from View Manager by removing the pool entry from both the Server Groups and Applications organizational units. However, removing one entry and not the other from the ADAM database results in the java.lang.nullpointerexception error when attempting to view the pools or desktops inventory in View Manager.
______________________________________________________________________________
7. Re-enable provisioning on the VDI pool.

8. Monitor the pool to ensure desktops are created successfully

Friday, August 10, 2012

DRS Rule Export \ Import

As the title says, this is a Powershell Method for exporting all of your DRS rules to a .txt file that can later be used to import the rules back into a cluster.

It is great for cases where you wish to keep a back of your rules or are looking to migrate to a new vCenter server and do not wish to manually create all your DRS rules again.

Export: 
$outfile = "C:\rules.txt"
$rules = get-cluster | Get-DrsRule
foreach($rule in $rules){   $line = (Get-View -Id $rule.ClusterId).Name   $line += ("," + $rule.Name + "," + $rule.Enabled + "," + $rule.KeepTogether)   foreach($vmId in $rule.VMIds){     $line += ("," + (Get-View -Id $vmId).Name)   }   $line | Out-File -Append $outfile }

Import: (Assumes your export was written to c:\rules.txt)
$file = "C:\rules.txt"
$rules = Get-Content $file
foreach($rule in $rules){   $ruleArr = $rule.Split(",")   if($ruleArr[2] -eq "True"){$rEnabled = $true} else {$rEnabled = $false}   if($ruleArr[3] -eq "True"){$rTogether = $true} else {$rTogether = $false}   get-cluster $ruleArr[0] | `     New-DrsRule -Name $ruleArr[1] -Enabled $rEnabled -KeepTogether $rTogether\     -VM (Get-VM -Name ($ruleArr[4..($ruleArr.Count - 1)])) }