VM Junkie

February 2, 2010

How to fix PCoIP VRAM issue with PowerShell, t5545 supports PCoIP now

Filed under: hp, powershell, thinclients, vdi, view, vmware — ermac318 @ 4:46 pm

Hi folks! Been a while, but I have a couple nifty tidbits here for you all:

A lot of folks have been having trouble with getting VMware View’s PCoIP to work in higher resolutions. This is caused by your Virtual Machine not having enough VRAM to power higher resolutions (since unlike RDP, PCoIP is using the “physical” video card of your Virtual Machine, as opposed to a virtual video device like RDP). There have been several workarounds:

  • Reset (not reboot) each VM once after it’s deployed. This is because when View clones your template, it fixes the VRAM issue but the VM is already powered on so the setting change won’t take effect until you restart the VM Monitor process. Reset does this. This was outlined in this XTRAVIRT KB article.
  • The better fix is to set your template’s VRAM properly. This is easier said than done, because there are bugs in the vSphere Client’s video settings dialog box that causes some settings (like the number of monitors) not to be written to the VMX file. So the only way to do this reliably has been to add the VM has an Individual Desktop in View Manager and have it do the settings properly. This was outlined at this That’s my View blog post.

That last one is obviously ideal, but it’s a pain and a waste of time to go through creating the pool. Even worse, if you made the mistake of building a pool out of the VM already, the View Manager prevents you from using the template VM as the source for an Individual Desktop!

So I wrote this PowerShell function that, when you feed it a VM object, will correctly set the VM to have enough Video RAM and display ports for 2 Monitors, each running at the max resolution of 1920×1200.

function Set-VRamSize ($vms)
{
	$vmviews = $vms | Get-View

    $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

    $line1 = New-Object VMware.Vim.optionvalue
    $line1.Key="svga.numDisplays"
    $line1.Value="2"
    $line2 = New-Object VMware.Vim.optionvalue
    $line2.Key="svga.maxWidth"
    $line2.Value="3840"
    $line3 = New-Object VMware.Vim.optionvalue
    $line3.Key="svga.maxHeight"
    $line3.Value="2400"
    $line4 = New-Object VMware.Vim.optionvalue
    $line4.Key="svga.vramSize"
    $line4.Value="36864000"

    $vmConfigSpec.extraconfig += $line1
	$vmConfigSpec.extraconfig += $line2
	$vmConfigSpec.extraconfig += $line3
	$vmConfigSpec.extraconfig += $line4

	$deviceSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec
	$videoCard = New-Object VMware.Vim.VirtualMachineVideoCard
	$videoCard.numDisplays = 2
	$videoCard.videoRamSizeInKB = 36000
	$videoCard.Key = 500
	$deviceSpec.device += $videoCard
	$deviceSpec.operation = "edit"

	$vmConfigSpec.deviceChange += $deviceSpec
	
	foreach($vm in $vmviews){
		$vm.ReconfigVM($vmConfigSpec)
	}
}

The script is also available on my Sky Drive.

In related news, the HP t5545 (along with a slew of other Linux-based Thin Clients) now supports PCoIP using the new client that you can download here.

Advertisements

September 11, 2009

PowerShell 2.0 RC out for WinXP/2003

Filed under: microsoft, powershell — ermac318 @ 9:11 am

The release candidate for PowerShell version 2.0 is now out for 5.x Kernel Windows versions (Windows XP and Server 2003). Download is available here. So far, looks like it works fine with PowerCLI to me.

Quick note: On the XP side, you must be running XP Service Pack 3.

September 2, 2009

VMworld session DV2801 – Integrating View into your Environment

Filed under: powershell, view, vmware, vmworld — ermac318 @ 10:58 pm

I arrived late to this session, but it looks like the beginning was about how to plug into today’s View product and make automated changes or fire off scripts based on events and such. The basics of it was the integration points you have today are very very limited – you have the two CLI tools (SVIConfig and VDMAdmin), log file monitoring, and editing the ADAM LDAP directly.

In View 4 new features will include an event reporting central warehouse – a database with a rollup of events from all clients, agents, and servers. It will include an event database with information on what events mean what along with resolutions, and will allow for querying using VDMAdmin or SQL tools such as Crystal Reports.

The best news though is PowerShell automation support! That makes View the 3rd product (after vCenter and Update Manager) to get PowerShell support. Using PowerShell should obviate the need to ever directly edit the LDAP, which is good because PowerShell can validate your input and will be far less dangerous. You can use PowerShell to stand up an environment from scratch, everything from global config, pairing it with a vCenter server, and making pools and VMs. You can also query the event warehouse for reporting purposes, and perform actions on sessions and VMs managed by View. Some examples:

#Set View License Key
Set-license -key AA113-XXXXX...
#Set the Pre-Login Message
Update-GlobalConfig -PreloginMessage "message"

#Update the power policy of a pool so you can preboot VMs at 5AM to avoid boot storm
Update-AutomaticDesktop -id DesktopJoe -PowerPolicy AlwaysOn
#Create a new Individual Desktop by using PowerCLI to get VM Object and pipe it to View CLI
Add-IndividualDesktop -id DesktopJoe -DisplayName "Desktop" -vm (Get-VM -name JoeVM)
#Entitle a user to a desktop
Get-User ADUserName | Add-DesktopEntitlement -desktop_id DesktopJoe
#Disconnect an active session
Get-ActiveSession -User "Joe" | Send-SessionDisconnect

This was the best news I’d heard all day. Finally, I can do all the neato stuff I can do in standard vCenter in View!

They then went into a bunch of Microsoft SCOM integration stuff which seemed pretty useless to me, and I was so buzzed from the PowerShell stuff I barely paid attention.

September 1, 2009

VMworld Session VM2241 – PowerCLI (4.0 Update 1 and Onyx)

Filed under: powershell, vmware, vmworld, vSphere — ermac318 @ 1:54 pm

One of the sessions I was most looking forward to today was the PowerCLI session from Carter and Friends. After teasing Project Onyx at their blog a few days back the anticipation was at a fever pitch.

Some great info in the session for PowerCLI newbies, but the good stuff was info on PowerCLI 4.0 Update 1 which is scheduled to be out “before Christmas” according to Carter (to which someone in the audience quipped, “what year?”)

  • PowerCLI 4u1 has 229 cmdlets in the current internal beta build
  • New cmdlets for vApps (get, new, start, stop, import, export)
  • Better Storage Management:
    • iSCSI improvements, get/set-vmhosthba.
    • You can now turn on the SW iSCSI initiator and add a Send Targets IP, rescan, and format LUNs all from PowerCLI.
  • Huge improvements to Guest operations.
    • Set-VMGuestNetwork (name approximate) allows you to set the networking information of Virtual Machines (Windows OR Linux with same syntax). Will be great for post-SRM failver scripting!
    • Copy files in and out of guests (Win or Linux)
    • Invoke-VMScript can run arbitrary commands and batch files (no longer requires PS in VM, can run BASH scripts in Linux VMs, too). Still require Host and Guest credentials.
  • NIC Teaming and Load Balancing policies
    • Set standby NICs, unused NICs, changed load balancing policy to IPHash, etc.
    • Forgot to ask if you can remove a VMNIC from a vSwitch yet…
  • vCenter Permissions and Role cmdlets.

Stuff I wish I had seen:

  • License management cmdlets (adding licenses to vCenter’s license database, assigning licenses to servers)
  • DPM Cluster- and Host-based cmdlets

Carter also said that performance in large vCenter servers will improve a lot – getting a single VM won’t take as long as getting them all.

The last thing was a demonstration of Project Onyx. Onyx is a proxy that sits in between your vSphere client and your vCenter server. It functions a lot like a sysinternals tool – you turn on “capture” and whenever you issue a command in the client it spits out PowerShell code that breaks out to the vSphere API to do what you just did. You then can save this to a PS1 file, edit out the stuff you don’t want to put in a script, generalize it (so it runs on a variable) and wrap it in a function.

The example they used was turning on DPM for a cluster. We ran Onyx and made the change to one cluster manually. Onyx spits out a giant chunk of code that creates a VMware.vim.ClusterConfigSpecEx object. We checked the API documentation to confirm that all the stuff related to HA and DRS (which we don’t want to modify) is optional, then remove all that junk from the code. We then wrap it in a function and call it using foreach object after grabbing all the clusters using get-cluster.

It’s a pretty slick process. I dropped off my business card to hopefully get into the Beta. Carter, hook a brotha up!

Lastly Scott Herold from Quest/Vizioncore showed off the Virtualization EcoShell, which I guess I’m way late to the party on but I’m totally switching to that from PowerGUI that I use now.

Overall GREAT session.

August 20, 2009

Powershell one-liner

Filed under: powershell, vmware — ermac318 @ 10:20 am

One of my favorite blogs as of late has been Arne Fokkema’s ICT-Freak, mostly because he enjoys posting little Powershell snippets that he writes. I find these one-liners are often very educational and often very useful, so I thought I’d start doing the same.

Recently at a customer site we migrated 100+ VMs from old storage to new storage, then upgraded them to vSphere. The customer left a few VMs on the old system however, and they asked for a way to identify them at a glance and how big they were. I cooked up this one-liner to list a bunch of VMs, their datastore, and their size in GB:

Get-VM | Select Name, @{N="Datastore";E={(Get-Datastore -VM $_).Name}}, @{N="VMSizeInGB";E={(get-harddisk -vm $_ | Measure-Object -Property capacityKB -sum).Sum / 1024 / 1024}}

May 7, 2009

When Powershell is a little bit TOO fast…

Filed under: esx, powershell, vmware — ermac318 @ 9:49 am

Last night I was doing a bunch of migrations on a severely overworked vCenter box, moving a bunch of VMs from an old cluster to a new one. I tried using it to do a bunch of cold migrations, i.e.:
$vmlist | Move-VM -Destination $desthost

Unfortunately, what happened was performing this on 40 powered off VMs initiates all 40 tasks at one. This really makes vCenter unhappy and it just kind of sits there staring at these 40 tasks “In Progress” and freezes up for a good 3 or 4 minutes. In one instance this actually failed and said “unable to communicate with remote host” and failed all the tasks after only 2 or 3 completed.

Unfortunately, rather than serializing these operations, it was just doing them in parallel. So I wondered, how could I serialize these and give the poor vCenter server a break?

$vmlist | % { Move-VM -VM $_ -destination $desthost
Start-Sleep -Seconds 5 }

Tada! By wrapping it in a foreach loop and adding a sleep, this made life much easier for my poor vCenter box. That’ll teach me to use the built-in SQL Express database…

April 7, 2009

Graphical help for VI Toolkit – Get-VITKHelp

Filed under: esx, microsoft, powershell, Uncategorized, vmware — ermac318 @ 3:25 pm

Just quickie here. The Microsoft ScriptCenter guys did something cool by providing a graphical help file for PowerShell along with a cool Get-GUIHelp function that let you jump straight to the help file from the command line. I modified their script (made it a lot shorter) and made it work with the VI Toolkit Reference Guide that’s provided with the Toolkit. If you are using the toolkit on an x64 machine, you may have to futz with the paths, but you should be able to figure it out:

 (more...)

March 12, 2009

PowerShell – Shutting Down an entire Infrastructure with vCenter as a VM

Filed under: esx, powershell, vmware — ermac318 @ 2:13 pm

Recently I wrote another PowerShell script to help automate something we do around here a lot. Most people probably don’t shut down their entire infrastructure terribly often, but at the company I work for we do a lot of demo environments, and we also do large demo events where we take a full pair of racks to a hotel to do technology demos. As such, we find ourselves shutting down everything rather often. This can be tricky sometimes, especially when vCenter is running as a VM.

I wrote the following script to shutdown all VMs running (except for vCenter), then shutdown all hosts not running vCenter’s VM, and then finishing up by connecting directly to the ESX box running vCenter to finish the job. This makes the process simple and repeatable. It even sets vCenter to autostart on the host its running on for when we need to power everything back on!

You can check it out on my Sky Drive.

February 24, 2009

VMWorld Europe in full swing, VirtualCenter 2.5 U4 is out

Filed under: powershell, vmware — ermac318 @ 10:06 am

So I try not to merely duplicate other people’s blog entries here on my blog. I figure if you want to read about the basic news from VMWorld Europe, or product releases, you can find that anywhere. All the blogs on my blogroll (to the right) are excellent and I highly recommend checking them out. There’s been some neat announcements already (I like the vCenter Heartbeat thing).

The other news which has seemed to dip under the radar is that included in VirtualCenter 2.5 Update 4, which was just released today, is a set of PowerShell cmdlets for Update Manager! This is awesome news. I will be installing this in our lab shortly and I’ll get back to you all with some info on it as soon as I can.

February 12, 2009

Clone-VM function

Filed under: powershell, vmware — ermac318 @ 3:46 pm

I added another file to my Sky Drive, it’s a PowerShell function that will Clone a VM using the VI Toolkit. If you’re on ESX 3.5u2 or newer the VM can even be running. This seems like kind of a big oversight in the toolkit – I would have assumed one could pass in an existing VM to the New-VM task, but you can only pass templates, and even those can’t be passed via the pipeline! Very disappointing.

So I wrote this function (with some guidance from forum posts, see the script comments) which does it for you in a fairly straightforward manner. I thought about writing a cmdlet to do it but I saw you needed Visual Studio to write them and my head exploded.

Older Posts »

Blog at WordPress.com.