Monthly Archives: August 2012

Creating hardware based device groups in Citrix Edgesight

If you want to organise your hardware into easy to view groups in edgesight, this is the post for you!

It can be extremely useful when retiring new hardware, or doing inventory as below:

Using your preferential database browsing tool, browse over to the edgesight database and view the contents of the DBO.Box_asset as below, this table will give you a view of the types of hardware on which you can create your reports:

Take a note of the Hardware types above and lets jump over to edgesight and start creating the groups.

Logged into the EdgeSight console, go to the configure tab, Device managementGroups:

Click the new group button:

On the new group tab, configure the relevant names and the options you require, below is an example:

Once happy with the options, click create group.

On the Member Type selection, choose Queries.

On the query page, select new query:

Name the query as you wish then paste the following in below (replacing %query% with the hardware type you have identified above).

Note: a % is the equivalent of a * in sql language.

select i.instid
from instance  as i inner join machine as m on i.machid = m.machid
inner join box_asset as b on b.boxaid = m.boxaid
WHERE b.model LIKE '%query%'

Once finished, click the test query button to ensure you have the results you desire in the window as above.

Assuming you are happy with your result, Click save query, Add query then next, then finally Finish.

Once complete, browse to Device Management, devices and in the dropdown you’ll see the newly created groups on which you can run reports.

Date and time shift when using Lotus Notes in Server 2008 R2 / XenApp

This was an extremely strange / rare issue, so I figured I would share it.

In this customers environment, they are using XenApp 6.5 on Server 2008 R2 for published desktops, this environment is a hosted desktop environment for a number of countries in Europe.

Infrequently an issue could be observed where the users timezones would shift out by one or two hours within the Lotus Notes application. This would case SameTime conversations and Calendar times to display out by the aforementioned value above.

When this issue occurred, it happened to all users on the server. A restart of the server did not fix the issue.

Interestingly, a “TZUtil /g” was reporting the client was in the correct time zone:

If you ran “TZUtil /s GMT Standard Time“, then closed and opened Lotus Notes… The problem was resolved for that user, in that session until they logged off.

It’s worth pointing out, that this issue was only seen in Lotus Notes, not in any other application, java or otherwise.

When comparing the TimeZone settings from a problematic server to a working server, I found the following difference:

These keys are stored under:

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTimeZoneInformation

And the working server looked as follows:

 

Now that is weird! So we copied the correct keys from the server to server and the issue was resolved. On all servers once users closed and opened Lotus Notes again.

But what caused this?

With a work around in place, I began to dig deeper into what caused the timezone to change on the servers despite the fact that no users have the ability to do so.

Analysing the logins to the servers, I spotted an administrator account logging into each of the servers as the day went by. This user didn’t log into the correctly working servers so this was the first clue.

Now if you’ve used Lotus Notes combined with XenApp and timezones before, you’ll know its a complete nightmare, interestingly the administrator in question (me, shamefully), was logging onto a XenApp session with a linux timezone to replicate an issue.

More embarrassingly, I then decided to Remote Desktop inside of the XenApp session to the affected servers, and with my admin account being who it was… inadvertently changed the timezone for the servers it seems.

That doesn’t sound right? You rdp’d from a client in a different time zone and it changed the server timezone?

I agree, but I have since been able to replicate this in a test environment. As with Server 2008 Microsoft now handle the timezone redirection themselves as part of group policy and administrative accounts will change the timezone of the server intermittently.

Now most customers probably wouldn’t even notice this, unless they are using lotus notes, as all other applications behaved correctly.

How do you work around this issue?

Ensure that the Group Policy you use to configure timezone redirection is configured to “not apply” to any local administrator on the XenApp server that may log in.

Batch installing type 1 fonts in Server 2008 R2 / Windows 7

This was such a massive pain, I sank way too much time into it so I figured I would share it. The font I was trying to install was needed by the customer, the font itself is called Helvetica light 45 as below:

Previously when installing this in server 2003, I just used the tried and trusted script from the Scripting guys here and it went off without a hitch. But with windows vista and above interactive session detection foils our lovely plans.

So moving on, what other options do we have? You could use:

  • The managed API AddFontResource (nope, type 1 fonts dont register the same way as typical fonts)
  • Using Visual Studio to create an MSI: (nope, see above)
  • Using a third party msi builder: (nope, see above)
  • Copy the files from the fonts directory from one machine to another (nope, something is missing)

So, after much hair pulling I hit a dead end.

I’ll spare you the details, but here’s an easy way to do it going forward:

  • install the font on a test machine:
  • Open command prompt as an administrator and browse to c:windowsfonts
  • find the font files here and copy them out to a working directory

  • Open regedit and browse down to:

hklm:softwaremicrosoftWindows NTCurrentVersiontype 1 installertype 1 Fonts:

  • Export this key to your working directory:

Move to the target machine:

  • Copy the fonts from the working directory to the fonts folder as above.
  • Import the registry key.
  • Restart the machine.

Tada!

If you know of an easier way to do this, be my guest to share it. But I dont want to look at a font file again for a very long time.

Using powershell as a replacement for the Change Logon command in Remote Desktop Services.

Still on my PowerShell buzz for the week, this is post 2 of 3 on some Remote Desktop Services / XenApp Powershell goodness!

This is one I’ve been meaning to post for quite some time, but other things got in the way. Mainly me forgetting how to use most of the powershell native methods due to having my head stuck in .net the last few weeks… Moving on…

While trying to find a method to check the status of logon’s to a Remote Desktop server via PowerShell, I didn’t have much luck. Either people are string scraping the output of the command using select-string or going to the registry and checking the raw Value with get-itemproperty. I wasn’t happy with either approach so I dug down into WMI and found the following.

From what I’ve found, the settings for enable, disable and the two drain modes are stored under the namespace rootcimv2terminalservices. Under the class Win32_terminalservicesetting.

There are two properties we are interested in here:

  • logons (0 = enabled, 1 = disabled*)
  • SessionBrokerDrainMode (0 = Disabled, 1 = DrainUntilRestart, 2 = Drain)

*why oh why 1 is disabled is beyond me, but I digress.

The order of priority is enabled / disabled first, before the drain options are referenced.

So what does this tell us? Well, a change logon /query is simply performing the following simple checks:

Change Logon /query

[sourcecode language=”powershell”]
gwmi win32_terminalservicesetting -N "rootcimv2terminalservices" | %{
if ($_.logons -eq 1){
"Disabled"}
Else {
switch ($_.sessionbrokerdrainmode)
{
0 {"Enabled"}
1 {"DrainUntilRestart"}
2 {"Drain"}
default {"something’s not right here!"}
}
}
}
[/sourcecode]

Ok that’s great and all, we’ve now replicated change logon /enable, but how do we set these values?

Easy! Using the native PowerShell $_.put() method, we can push values back in.

Below you will find each “Change Logon” option in server 2008 R2 and the corresponding WMI property.

Change logon /Enable

[sourcecode language=”Powershell”]
$temp = (gwmi win32_terminalservicesetting -N "rootcimv2terminalservices")
$temp.sessionbrokerdrainmode=0
$temp.logons=0
$temp.put()
[/sourcecode]

Change Logon /Disable

[sourcecode language=”Powershell”]
$temp = (gwmi win32_terminalservicesetting -N "rootcimv2terminalservices")
$temp.logons=1
$temp.put()
[/sourcecode]

Change Logon /Drain

[sourcecode language=”Powershell”]
$temp = (gwmi win32_terminalservicesetting -N "rootcimv2terminalservices")
$temp.sessionbrokerdrainmode=2
$temp.put()
[/sourcecode]

Change Logon /DrainUntilRestart

[sourcecode language=”Powershell”]
$temp = (gwmi win32_terminalservicesetting -N "rootcimv2terminalservices")
$temp.sessionbrokerdrainmode=1
$temp.put()
[/sourcecode]

And that’s it! now if you want to wrap this up in a function be my guest, or if you would like me to do so just drop me a line.

Checking the status of Dynamic Fair Share Scheduling in Server 2008 R2

It’s been ages since I did a good techy /Powershell blog post so here’s the first of a few “quick hit” posts I’ll be publishing in the next few days.

Dynamic Fair Share Scheduling is a fantastic feature that Microsoft included in Server 2008 R2 to reduce contention for CPU time for users. Once enabled the fare share scheduling will happily allow users to burst all CPU resources when needed, but interrupt them abruptly when another user requires resource. I’m a massive fan of this technology and even wrote a tool to provide more functionality to this technology. (ThreadLocker)

That being said, it can be quite difficult to confirm whether DFSS is working or not, and there’s even a broken Group Policy setting as documented here to make things more confusing.

If you need quick and reliable confirmation that DFSS is enabled and running, try the following powershell command which will pull the information via WMI:

(1 = turned on, 0 = turned off)

[sourcecode language=”PowerShell”]
(gwmi win32_terminalservicesetting -N “root\cimv2\terminalservices”).enabledfss
[/sourcecode]

Similarly, if you want to turn it off using powershell, try the following: (This will require a restart)

[sourcecode language=”PowerShell”]
$temp = (gwmi win32_terminalservicesetting -N “root\cimv2\terminalservices”)
$temp.enabledfss = 0
$temp.put()
[/sourcecode]