Tag Archives: XenApp

PowerShell Windows XenDesktop

Get running processes including CPU and memory usage

One of my customers needed a PowerShell script to get all running processes with their corresponding CPU load. This was script should be triggered by their monitoring system if the system total CPU usage exceeds a configured threshold.

They’re running a mid-sized Citrix XenDesktop farm with Server-OS (formerly known as XenApp a.k.a. terminal services) and sometimes applications are using a high CPU amount.

This is the small script I wrote for them:

#####################################################################
##
## (C) 2015 Michael Miklis (michaelmiklis.de)
##
##
## Filename:      Get-Tasks.ps1
##
## Version:       1.0
##
## Release:       Final
##
## Requirements:  -none-
##
## Description:   PowerShell Tasklist with CPU usage and memory
##                usage
##
## This script is provided 'AS-IS'.  The author does not provide
## any guarantee or warranty, stated or implied.  Use at your own
## risk. You are free to reproduce, copy & modify the code, but
## please give the author credit.
##
####################################################################

<#
.SYNOPSIS
Lists all running task including cpu and memory usage

.DESCRIPTION
The Get-Tasks function uses Windows Management Instrumentation (WMI) to retrieve process Name, ProcessId, SessionId,
VirtualSizeMB, Handles, Owner, PercentProcessorTime and ThreadCount

.PARAMETER computerName
Computername or IP Adress of the computer to query

.PARAMETER credential
Credentials to query computer as System.Management.Automation.PSCredential

.EXAMPLE
Get-Tasks
Get-Tasks -computerName "server.domain.com" -credential $credential

.NOTES
You need to run this CMDlet with elevated permissions
#>

function Get-Tasks {
    [CmdletBinding()]
    param (
        [parameter(Mandatory=$true,ValueFromPipeline=$false)]
        [string]$computername,

        [parameter(Mandatory=$true,ValueFromPipeline=$false)]
        [System.Management.Automation.PSCredential]$credential      
    )

    PROCESS {
        $colProcs = Get-wmiobject win32_process -computername $computername  -Credential $credential | select *,@{Name=”Owner”;Expression={($_.GetOwner()).User}}
        $colPerfs = Get-wmiobject win32_perfformatteddata_perfproc_process -computername $computername  -Credential $credential 
        $colTasklist = @()

        foreach ($proc in $colProcs) {
            $process = New-Object System.Object

            $perf = $colPerfs | Where-Object { $_.IDProcess -eq $proc.ProcessId }

            $process | Add-Member -type NoteProperty -name "Name" -value $proc.Name       
            $process | Add-Member -type NoteProperty -name "ProcessId" -value $proc.ProcessId
            $process | Add-Member -type NoteProperty -name "SessionId" -value $proc.SessionId
            $process | Add-Member -type NoteProperty -name "VirtualSizeMB" -value ([math]::Round(($proc.VirtualSize / 1024 /1024), 2))
            $process | Add-Member -type NoteProperty -name "Handles" -value $proc.Handles
            $process | Add-Member -type NoteProperty -name "Owner" -value $proc.Owner
            $process | Add-Member -type NoteProperty -name "PercentProcessorTime" -value $perf.PercentProcessorTime
            $process | Add-Member -type NoteProperty -name "ThreadCount" -value $perf.ThreadCount

            $colTasklist += $process
        }

        $colTasklist | Sort-Object PercentProcessorTime -Desc

        return $colTasklist
    }
}
Read More
Windows XenApp XenDesktop

SESSIONID.EXE – Query Terminalserver Session ID

DOWNLOAD
sessionid.exe

I was looking for a way to display the session-ID of my current terminal server session regardless of the protocol I’m using in a batch file. I tried numerous workarounds by parsing the output of qwinsta.exe or quser.exe – but both ways didn’t work in a reliable manner.

After some research, I figured out that the session ID is available as a property within the .NET Framework. Therefore, I decided to write a small executable that will output the session id.

SessionID

Attached to this post you’ll find the SESSIONID.EXE – feel free to use it within your project.

Here are some code snippets how to use the sessionid.exe:

FOR /F "tokens=*" %%A IN ('sessionid.exe') DO SET SESSIONID=%%A
ECHO %SESSIONID%
Read More
XenApp XenDesktop

Change Clientdrive Name and Icon (Example: Mein IGEL)

Today I created a script to make it easier for IGEL Linux ThinClient users to find their client USB drives. On IGEL Linux ThinClients, all USB client devices are mapped under the virtual client drive A: (clienta$). Unfortunately, it isn’t that easy to recognize for the regular users in the Windows Explorer if they are connected to a XenApp or XenDesktop machine.
Therefore I decided to make it a lot easier for the User – and here we go – that’s how it looks now:



So what do we need to do to get there? I wrote a batch script that does the Job for you – this script needs to be run everytime a user logs on to the XenApp or XenDesktop session. This can be done with the regular login script or with group policy preferences – for my first implementation I did it with GPP and used item level targeting for specifying an Active Directory Group.

Here’s the Script:

MeinIGEL.cmd

You need to customize the Script regarding the path to the IGEL icon file to fit your environment. For Copyright reasons, I can’t offer an IGEL icon file for download – you have to create your own.

Read More
XenApp

Citrix XenApp Commands Remoting Service does not start

On Citrix XenApp 6.5 Server the service ‘Citrix XenApp Commands Remoting Service’ fails to start:

if the following conditions are true:

  • Certificate Revocation Checking is enabled (Windows default)
  • A Proxy Server is needed for internet access
  • No internet access is possible

Cause

This issue occurs because the ‘Citrix XenApp Commands Remoting Service’ tries to perform a certificate revocation check and fails.

Resolution

You need to create a XML file with the name ‘Citrix.XenApp.Commands.Remoting.Service.exe.config’ in the directory ‘C:Program FilesCitrixXenApp Commands’.

Open the created file with a text editor like notepad and insert the following lines:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <generatePublisherEvidence enabled="false" /> 
  </runtime>
</configuration>

Save and close the file. Now you will be able to start the service.

Read More
XenApp

Citrix SSL Relay Configuration Error 58

When using Citrix SSL-Relay I received the following error:

I’ve checked all the basic stuff:

  • Certificate is installed in the computer account -> [-OK-]
  • Private Key is present -> [-OK-]
  • FQDN of the Certificate and the server are matching -> [-OK-]
  • Certificate Template Version: Windows 2003 Enterprise -> [-FAILED-]

My certificate was issued based on a certificate template with a minimum requirement of Windows 2008 Enterprise PKI. However all PKI Servers ARE Windows Server 2008 R2 Enterprise and issuing the certificates based on the template – there are some major differences within the issued certificate whether the template has a minimum of Windows 2003 Enterprise or Windows 2008 Enterprise – regardless of the Version the issuing CA server is running (CryptoAPI vs. CNG).

So I needed to create another copy of my certificate template but now I’d chosen “Windows Server 2003 Enterprise” as a minimum and issued a new cert for my SSL-Relay Server:

After this, the configuration and activation of SSL-Relay worked like a charm:

Read More
XenApp

Citrix SSL Relay Configuration / APPCRASH sslrelayconfig.exe

In some environments, the Citrix SSL Relay Configuration will crash with the following message at startup:


After a little, research I found a Citrix support article that describes my problem:

http://support.citrix.com/article/CTX112483

But from my opinion this is not a Resolution of the real problem – this seems more likely a workaround to me. So I did some further inspections what the root cause of this APPCRASH could be. The Citrix article stated something about a missing friendly name – and viola one of my installed computer certificates had no friendly name.

This is really easy to change and therefore I just entered a friendly name to the certificate within its properties:

Unfortunately, the same error is still present – APPCRASH in sslrelay.exe. So I needed to dive a little deeper. After some further investigations, I realized that the missing Subject causes also problem:

Because all Certificates were issued by our corporate public key infrastructure so we just modified the corresponding template with the following settings on our CA server:

And finally Citrix SSL-Relay Configuration is starting without an error!

Read More
XenApp

Citrix XenApp XML Service shared with IIS not working after sysprep

A coworker of mine had problems regarding Citrix XenApp XML Service shared with IIS7 on a syspreped Windows Server 2008 R2. After a little research and investigations I found a Citrix support article regarding this problem:

http://support.citrix.com/article/CTX131137

Here’s also a short guide how to configure IIS portsharing with Citrix XML Service:

http://support.citrix.com/article/CTX125107

Read More