Think IPM

Wednesday, November 30, 2011

PowerShell Tutorial – How to Keep Tabs on XenApp Printer Queues

Sam Jacobs posted a great PowerShell script and tutorial on IPM’s corporate blog that I wanted to share with everyone.

A few weeks ago, a client of ours began noticing that printer queues on certain XenApp servers were experiencing errors, and jobs sent to those queues were left stranded and never printed. As it turned out, the problem was caused by an updated printer driver, and the issue only occurred when that printer driver was used.

Since there were quite a few servers involved, with 10-20 print queues per server, it seemed like a job for a WMI script. The first version (a .VBS script) looked something like this:

strServer = "."
strQuery = "SELECT * FROM Win32_PerfFormattedData_Spooler_PrintQueue "

Set
objWMIService = GetObject (“winmgmts:\\” & strServer & “\root\CIMV2″)
Set colItems = objWMIService.ExecQuery (strQuery)

Wscript.Echo “Printer” & vbTab & “Jobs” & vbTab & “JobErrors”
For Each objItem In colItems
WScript.Echo objItem.Name & vbTab & objItem.Jobs & vbTab & objItem.JobErrors
Next

Set
objWMIService = Nothing
Set colItems = Nothing

While the above worked just fine, due to the varying length printer names, the resultant output was a bit difficult to read. Here’s what the output looked like when run on my local machine:

PowerShell to the rescue! In order to get the same output, only a single line is needed to get the same results in PowerShell (while wrapped here for readability, it may all be placed on a single line):

Get-WMIObject Win32_PerfFormattedData_Spooler_PrintQueue -computerName . |
Select Name, Jobs, JobErrors | ft –auto

The command above uses the Get-WMIObject cmdlet to read the print queues of the current server, pipes the output to select the desired fields: Name (printer name), Jobs (Number of Pending Jobs), and JobErrors (Number of Errors), and pipes the output to the Format-Table cmdlet (alias: ft) to automatically give us a nicely formatted table:

Much easier to read!

Now let’s add two additional features. First of all, we need to be able to cycle through the print queues of all our XenApp servers. While this could be done by importing the Active Directory PowerShell module and using some AD cmdlets, it’s pretty easy to just create a file with the names of the XenApp servers. This way, we don’t need to add any additional software to the XA servers.

Since we’re only interested in printers that have errors, it would also be nice to highlight only those printers which have jobs pending (signaling a possible problem).

Here is the PowerShell script with the above features added:

$servers = Get-Content 'CitrixServerList.txt'  
ForEach ($server in $servers) {
try {
write-host "Processing printers for: " $server " ..."
Get-WMIObject Win32_PerfFormattedData_Spooler_PrintQueue
-computerName $server -ea stop |
?{$_.jobs -gt 0} |
Select @{Expression={$_.Name};Label=$server+" printers"},
Jobs, JobErrors |
ft -auto
} catch [System.Exception] {
write-host $server "...cannot retrieve printer names"
}
}



First, we retrieve the list of XenApp servers (with one server per line in the text file).

We then cycle through each server, wrapping the code in a try/catch block to handle errors (in case one of the servers is offline, for example).


The new parts of the script above:



-computerName  $server    the XenApp server name from the ForEach command
-ea stop set the ErrorAction (ea) to stop processing the command if an error occurs
?{$_.jobs -gt 0} only show printer queues with jobs pending


The term @{Expression={$_.Name};Label=$server+” printers”} shows how to rename column headings in the output.



Output of the final version above:






Click Here to Continue Reading >>

Monday, November 28, 2011

Registry String Redirection / IPM Utility: Get@String

Jacques Bensimon sent over a great little registry utility and whole lot of education!  Read on …

Have you noticed that, starting with Vista/2008, some previously descriptive Registry entries (such as the names and descriptions of most system services, the descriptions of some file types under HKEY_CLASSES_ROOT, etc) are no longer in plain English (or whatever the language of the Windows installation) bur rather look like the highlighted values in the following screenshot?

clip_image002

These entries of the form “@filepath,-###” are examples of what Microsoft calls Registry String Redirection (http://msdn.microsoft.com/en-us/library/windows/desktop/dd374120(v=vs.85).aspx) and are designed to keep the Registry “language-neutral” by replacing language-specific text with references to string resources somewhere in the file system.  For example, the DisplayName entry in the above screenshot, “@%SystemRoot%\system32\bdesvc.dll,-100”, is to be interpreted as “the string resource with ID 100 in the appropriate MUI language resource file for bdesvc.dll”, such as %SystemRoot%\system32\en-US\bdesvc.dll.mui.  This can be looked up for example with Resource Hacker, as in the following screenshot:

clip_image004

So now I know that BDESVC is the “BitLocker Drive Encryption Service” (that’s a relief:  I feared it might be the return of the Borland Database Engine!)

While Resource Hacker can be used in this roundabout fashion to retrieve the contents of redirected Registry strings, I thought a more direct solution might be useful, so here’s Get@String (the archive contains both 32-bit and 64-bit versions of the utility).  It can take a redirected string specification on its command line or it can be run interactively as follows:

clip_image006

results in

clip_image008

and changing the string ID to 101 results in

clip_image010

Later,
JB

Click Here to Continue Reading >>

Thursday, November 24, 2011

Happy Thanksgiving from vCloudInfo, HyperVInfo & VMwareInfo.com!

imageJust a quick note to wish everyone and their families a great Thanksgiving this year!  Hopefully, you are eating well, watching some football and getting ready for some Black Friday madness.

I appreciate your readership, comments and overall participation in the blogging community.

I also wanted to say thanks to our direct sponsors for their support and sponsorship of my blog.  Be sure to check out their websites while shopping this extended holiday weekend!

imageimageimageimageimage

Click Here to Continue Reading >>

Monday, November 21, 2011

How to Add a 3rd Party driver to a baseline in Update Manager

Working with the Nutanix clusters, I had an opportunity to upgrade them to vSphere 5 via Update Manager.  The process of upgrading an ESX host with Update Manager is pretty straight forward with the exception of 3rd party drivers.  For Nutanix, they use a Mellanox 10GB card that is not part of the base ESXi build.  This requires us to create an extension driver to support the additional 10GB card with ESXi 5.

The first part of this process is to import the OFFLINE BUNDLE ZIP that contains the VIB file and metadata for the driver.  This can usually be downloaded from VMware or the 3rd party vendor. (Here is a link to the Mellanox driver.)

image

After successfully importing the driver, vCenter will connect and download any required bulletins or notifications associated with the driver.
image
Next, you will need to create an update baseline.  From Update Manager, choose Create New Baseline

image
I had previously created a v5.0 upgrade baseline for ESX5.  You can create one by downloading the ESXi ISO from VMware and uploading it into VMware Update Manager.
imageimage
Next, you will be prompted to create the Extension Base.
image

image
You should see the new driver just imported in the list.  Move it into the extension to add box to create the Baseline Extension.
image
Once created, you will be returned to the New Baseline Wizard.
image
image
You now have an ESXi 5 baseline with a host extension that you can point at your ESX 4.1 servers to upgrade.  In this case, I attached it at the Nutanix Cluster level and upgraded all 4 nodes successfully via VMware’s Update Manager.

image

Click Here to Continue Reading >>

Thursday, November 17, 2011

RANT: Does Microsoft offer adequate SPAM protection for their Cloud Mail service?

That fact that these types of emails and attachments are getting past Microsoft’s Forefront SPAM server is pretty inexcusable.   It truly baffles me how the Microsoft Outlook JUNK Filter can flag these messages as harmful but the Hosted Server side product let’s them right through untouched.

 imageimage

 imageimage

I do not know how this level of service can be considered enterprise ready.
TIP: Be sure to evaluate the level of SPAM protection offered by a hosted mail service before migrating to the cloud. Sad smile
Click Here to Continue Reading >>

Monday, November 14, 2011

Not enough room for vSphere 5 Upgrade? Free some up!

While using VMware’s Update Manager to upgrade a 4.0 ESX host to vSphere 5, I ran into a space issue.  Looking at the event tab on the ESX host in question, the error stated that at least 297 MB free space was required for the upgrade.

image

A quick putty session to verify the actual free space on the host and I noticed the following suspicious esx3 folders taking up a considerable amount of space.  These folders were remnants left over from the ESX3 to 4 upgrade.  The folders were there to allow for a roll back.  They were never cleaned out and were preventing my upgrade now.

image

Fortunately, VMware has a nifty little command called cleanup-esx3 which when run will clear out these unnecessary files.  Once removed, you can no longer roll back to ESX3.  Most likely not an issue. Winking smile 

image

After a quick reboot, the folders and mount points are removed from the system.

image

You can also remove the folders manually.  Once the necessary space was freed up, rerunning the Update Manager task did it’s thing.

Click Here to Continue Reading >>

Thursday, November 10, 2011

My blogger blog was GONE.

image

Yeah .. That freaked me out this morning! Not exactly sure what happened.. After logging out and then back into Google, my VMwareInfo.com blog seemed to have been restored.  I am assuming this was a minor glitch on the blogger platform but it FREAKED ME OUT.

After some research, I found a pretty neat service called Backupify that backs up other online services.  Facebook pages, LinkedIn, Twitter, Blogger and a host of other services that contain things you might not want to lose.  The service is a great idea.  Not just for accidental deletions but also for whole company failures.  I am sure you could use the data stored on the Backupify servers to migrate from one service to another.  Especially useful as cloud services come and go.  

Like most cloud services, they have a free plan and this one allows for up to 5 GB of backed up data.  Once you either hand over some credentials or allow access via OAuth, Backupify connects over and begins to back up your data.
image

Once you have a successful backup, you can drill down into the backup archive and pick out individual items from the backup for export.   The formats I have seen for exporting have only been JSON but I don’t know if they change based on the service you decide to backup.

SNAGHTML281728

Might not be the perfect safety net but for the price, it’s better than what I had before and it would have eased some of the panic I felt this morning. Winking smile

Click Here to Continue Reading >>

Wednesday, November 9, 2011

Quest Discontinues vConverter.

SNAGHTML14f0e2ddThis shouldn’t really come as a surprise to anyone since the whole P2V space is really now just a niche tactical market anyway. I would imagine that MOST of the physical boxes that are candidates for virtualization have been either P2V’d already or will be taken care of by VMware’s free VMware Converter.
 
VMware put out a really great free product that made it very difficult for clients to justify paying for a third party solution like vConverter or PowerConvert. I would imagine you might see some of these products morph into or resurface as cloud migration tools helping Virtual Infrastructure administrators migrate VMs from on-premise to off-premise clouds.
 

Partner Notification

vConverter has reached the end of its product life (EOL) and will be discontinued as a product offering by Quest Software according to the timeline listed below.

Wednesday, November 30, 2011:  End of Sales

Wednesday, November 30, 2012:  End of Support

New sales after the end of sales date on November 30, 2011 will not be allowed.
Renewals will only be allowed up to the end of the support date on November 30, 2012. 

Effective immediately, please stop selling vConverter and remove the impacted part numbers from your price lists.

Click Here to Continue Reading >>

Monday, November 7, 2011

Quick Tip: Pin to the Start Menu or NOT…

imageHere’s a quick tip I learned by sitting next to Jacques Bensimon today.  If you want to control whether an application is ‘allowed’ to be pinned to the Start Menu or Taskbar, head into the registry and navigate over to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileAssociation
and check out the AddRemoveNames key.  If an application has one of the words in this key, you will not be able to pin it.  I ran a quick test using Revo Uninstaller (<-Great app BTW).  The word install is listed in AddRemoveNames so I wasn't presented any Pin options.

SNAGHTML1099a846

You can see that there is no option for pinning on the right click menu.

image

Remove the word install from the key string, restart Explorer, and you’ve enabled the ability to Pin for that application.
image

Nice and easy way to restrict or enable a user’s ability to pin things in a Citrix XenApp or VDI image.

Click Here to Continue Reading >>