PowerCLI vCheck 5.47 – Additional RAM checks

Todays update includes two new sections to the general reporting section of the report. These sections are not configuration issues/problems, just additional information about your environment.

# Version 5.47- bwuch: Added memory per cluster check provided by Ed
# Version 5.46- bwuch: Added vRAM check using @LucD function

5.46 – Added @LucD’s function Get-vRAMInfo from http://www.lucd.info/2011/07/13/query-vram/. This function checks vRAM allocations against vSphere 5 licensing allocations. This check includes version all hosts — even those not running version 5.0. It is important to note the new licensing does not take effect until/unless you upgrade. This check is included for planning purposes.
5.47 – Added code provided by a reader named Ed in the comments for the vCheck 5.40 post. It shows the amount of allocated RAM per MB of physical RAM in a cluster. His comments are available here.

You can download the updated version here: vcheck5.47.ps1

Posted in Scripting, Virtualization | 8 Comments

View 5.0 preseal-cleanup script

When composing a View Composer desktop there are a handful of tasks that need completed. I created a script to help me keep this quick and consistent:


REM Cleanup temp/log files
del /s %temp%\*.* /q
del "C:\Documents and Settings\All Users\Application Data\VMware\VDM\*.*" /q

REM Blank out the bginfo.bmp image while leaving permissions in tact
echo > C:\WINDOWS\bginfo.bmp

REM Delete the McAfee GUID...a new one will be issued at boot up
reg delete "HKLM\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent" /v AgentGUID /f

REM Release the IP address
ipconfig /release

REM Shutdown the workstation
shutdown -s -t 5

Please leave a comment if there are any other ideas or additions you can think of!

Posted in Scripting, Virtualization | Leave a comment

Enable vSphere console copy/paste without power off — the PowerCLI way

I’ve had an ongoing love/hate relationship with security for years. Today it was heavy on the hate. I rarely have a need to copy/paste between my desktop and a VM console. I normally use some other method to connect to a VM (ssh, Remote Desktop, etc) but today I was testing some Powershell code in an isolated lab environment. The only way to see what is going on is through the console, as there is no IP connectivity between me and the lab. I wanted to write code in the script editor on my desktop and paste it into the VM console, and that’s where I started to run into problems:

Clipboard Copy and Paste does not work in vSphere Client 4.1 and later http://kb.vmware.com/kb/1026437

The solution listed in the code works, but modifying those settings inside the GUI requires the VM to be powered off. Who wants to do that? Not me.

Instead I re-used some previously written PowerCLI code and a stun/unstun operation (i.e. power on/off, suspend/resume, create/delete snapshot/storage VMotion) to achieve the same thing.


#Clipboard Copy and Paste does not work in vSphere Client 4.1 and later
#http://kb.vmware.com/kb/1026437

$copy = New-Object VMware.Vim.optionvalue
$copy.Key="isolation.tools.copy.disable"
$copy.Value="FALSE"

$paste = New-Object VMware.Vim.optionvalue
$paste.Key="isolation.tools.paste.disable"
$paste.Value="FALSE"

#Create a Machine Config Spec using the three option values specified above
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += $copy
$vmConfigSpec.extraconfig += $paste

#Get a VM View collection of all the VMs that need to have these options
$vms = get-view -viewtype virtualmachine |where {$_.name -eq "lab-dc01"}
foreach($vm in $vms){
$vm.ReconfigVM($vmConfigSpec)
}

This code creates a ReconfigVM specification that includes the values required for both copy and paste operations into the vSphere client. It then applies it to a VM named lab-dc01. (If you wanted, you could change the -eq (equals) to -like or -match to get more than just one VM.)

After running the code you just need to complete a stun/un-stun operation (in my case, I did a storage VMotion as I needed to move the VM to a different datastore anyway) and now we are in business.

Oh, and to keep the security people happy, I should mention that you need to change the FALSE values to TRUE and run the script again when you are complete. We wouldn’t want to allow future copy/paste operations now, would we?

Posted in Scripting, Virtualization | 2 Comments

View 5.0 Upgrade issues

I recently upgraded a View 4.6 installation to 5.0. The update went pretty well until I went to update the View agent inside the desktop sources. The install kept failing with the following error message:

Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action VM_RegisterPcoipPerf32, location: ...\pcoip_perf_pr...

After a bunch of searching/testing, I finally realized that McAfee On Access Protection was blocking the ability for the composer agent to register as a service. McAfee exclusion in place, I continued to have issues with the installer, so I removed VMware Tools and cleaned up all of the VMware installer bits using the tool in this KB:

Cleaning up after an incomplete uninstallation on a Windows host (http://kb.vmware.com/kb/1308)

After a reboot I was able to install the View 5.0 Agent and then I finally re-installed VMware Tools and recomposed my desktops. Now for the next error, which showed up in the View Connection Server/Admin console after attempting to deploy these new linked clones:

View Composer agent initialization state error (-1): Illegal state (waited 0 seconds)

I couldn’t find much documentation on this error…but after searching through some of the agent logs, I realized that the “VMware View Composer Guest Agent Server” service wasn’t installed in my guest VM. It appears this option only exits in the View Agent installer if VMware Tools is already installed in the VM. Re-running the View 5.0 Agent installer gave me the option to install the composer agent and thin print support.

Lessons learned

  • Disable antivirus protection before starting View Agent upgrade
  • Install/Upgrade VMware Tools before View Agent
  • Posted in Virtualization | 1 Comment

    PowerCLI vCheck 5.45 – Updated export options

    I started working on this update in the airport the Sunday before VMworld 2011. It is only a minor update to exporting the reports and sending email notifications. In this update, all of the code to send emails and/or export reports has been moved to a function near the top of the code and at the very end of the script (where the export code used to be) I added a call to this function. I think it is now easier to see/edit/understand your output options.

    # Version 5.45- bwuch: Updated export options
    

    5.45 – Minor update to the Out-File and Send-MailMessage code; moved into a function in the “config” part of the script and then called from the end.

    You can download the updated version here: vcheck5.45.ps1

    Posted in Scripting, Virtualization | 2 Comments