Saturday, May 28, 2011

Citrix: Changing XML port number

To determine which port is being used, either look in the Citrix Access Management Console or locate the following registry key (assuming IIS port sharing is not being used):
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CtxHttp
Value: "TcpPort"













Unregistering the XML Service
  1. Open a command Prompt window.
  2. Run ctxxmlss /u (This command unregisters the Citrix XML Service and marks it for deletion).
Registering the XML Service on a port other than sharing with IIS
  1. Unregister the service using the previous instructions.
  2. Open a command Prompt window.
  3. Run ctxxmlss /r[Port Number] (Notice that there is no space between the switch “/r” and the port number.
  4. Open the service control manager and manually start the Citrix XML Service.
Note: During the unregister/register process you might see the below error message. There is no need to reboot the server. Just run the Unregister command again, go to services and attempt to start the service then Reregister the service.
Could not start the Citrix XML Service service on Local Computer.
Error 1060: The specified service does not exist as an installed service.



Tuesday, May 24, 2011

How to check what version of Microsoft .NET Framework is installed on a computer

You can manually check what version of Microsoft .NET Framework is installed on your computer from Add or Remove Programs. This is a very basic way to check but could be wrong because the entries that is displayed in Add or Remove Programs can be easily removed from registry.

A better way would be to use this free and portable ASoft .NET Version Detector. It is a lightweight tool that gives information on the different versions of Microsoft .NET that are installed on a machine.

Click HERE to download .NET Version Detector 2007.

Citrix: Some trouleshooting tips

  1. Which action will enable an Administrator to configure the Citrix XenApp farm to check the Local Host Cache (LHC) automatically for corruptions and to send alerts when there is a corruption?

    Ans: Add the CheckLHC.exe to the Healthe Monitoring and Recovery section
     
  2. ServerA is experiencing connectivity issues communicating with Zone Data Collector. Upon examination, an Administratro determines that server to server communication has failed on one of the servers in the environment. The Administrator would like to verify that appropriate ports are opened in the environment. He should use following two commands to determine if the correct port is listenning on the servers.

    NETSTAT -A
    TELNET ServerA 2512
     
  3. The Administrator of a Citrix XenApp farm enabled ICA Keep-Alive, but notices that the ICA Keep-Alive settins are NOT being used. What could the Administrator have done to prevent the ICA Keep-Alive settings from being used?

    Ans: The Administrator have enabled Session Reliability
     
  4. If the data store is experiencing high CPU usage when there should not be significant read or writes to the data store, it is possible that the data store is not powerful enough to manage a query interval of 30 minutes. To determine whether or not the data store query interval is causing the high CPU usage on the data store, you can set the query interval to a very large number and test CPU usage. If the CPU usage returns to normal after you set a large query interval, the data store query interval is probably the cause of the high CPU usage. You can adjust the query interval based on performance testing.

    To test the query interval, set the interval to 60 minutes and then restart all the servers in the farm. If the data store is still experiencing constant high CPU usage, increase the query interval further. If the CPU usage returns to normal, you can try a smaller value. Continue these adjustments until data store CPU usage is normal.
     
    Important: Do not set the data store query interval higher than necessary. This interval serves as an important safeguard against lost updates. Setting the interval higher than necessary can cause delays in updating the local host cache of the farm’s member servers.

Monday, May 23, 2011

Citrix: PowerShell script to check XenApp offline servers and send only incremental records

Existing scenario:
The PowerShell script checks for offline servers and stores the record in a log file. The script is scheduled to run on every 1 hour. It overwrites the existing log file and then send the log file by email.

Requirement:
The script will check for existing offline server(s) record in the log file and then send only newly added records (delta changes) by email.

Add-PSSnapin citrix.XenApp.Commands

$Log_File="C:\OfflineServers.log"
$DeltaFile = "C:\OfflineServers-Changed.log"

# Executing the command to check for Offline Server and stores in a log file
$ExistingList = Get-Content $Log_File
$NewList = QFARM /OFFLINE

# This defines newly added entries, ignoring removed entries
$DeltaList = Compare-Object $ExistingList $NewList | 
  Where-Object { $_.SideIndicator -eq '=>' } |
  Select-Object -ExpandProperty InputObject

# Write that to a temp file for the attachment
$DeltaList | Out-File $DeltaFile -Encoding ASCII

# Save the complete list
$NewList | Out-File $log_file -Encoding ASCII

#Sending Email
$smtpServer = "<SMTP Server Name>"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($DeltaFile)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "<From Email Address>"
$msg.To.Add("<To Email Address>")
$msg.Subject = "Offline Servers"
$msg.Body = "List of Offline Servers"
$msg.Attachments.Add($att)
$smtp.Send($msg)
$att.Dispose()

Thursday, May 19, 2011

PowerShell: Getting computer name for specific event ID

Requirement
I want to list all the Citrix servers for specific event ID that generated within 7 days - for example System Event ID 3621.


If  any servers found with that specific Event ID, then the server list will be emailed. Else it will not send any email.

Step-1: Translate EventID to InstanceID

Sometimes, you may need to have the event ID for a system event, though what you really need is the instance ID. For example, Get-EventLog will only support instance IDs, but no event IDs. Here is a script that can translate event IDs into instance IDs.

Execute the following script to get the Instance ID of that specific Event. Enter the event ID in "EventCode=xxxx" section. The Instance ID will be shown under EventIdentifier field. Here the Instance ID is 2147749413 for Event ID 3621

get-wmiobject Win32_NTLogEvent -filter "EventCode=3621" -ComputerName <put server name here>

Output
Category             : 0
CategoryString    : 
EventCode          : 3621
EventIdentifier : 2147749413
TypeEvent          : 
InsertionStrings   : {IMA_RESULT_DBCONNECT_FAILURE}
LogFile               : System
Message           : The server running Citrix Presentation Server failed to connect to the Data Store.  Error - IMA_RESULT_DBCONNECT_FAILURE. The database is down or there is a network failure.
                   
RecordNumber  : 1324
SourceName      : IMAService
TimeGenerated   : 20110518112620.000000+330
TimeWritten       : 20110518112620.000000+330
Type                  : Error
UserName         : 

Step-2: Script to list servers

Just copy and paste the following section of PowerShell code and change the Instance ID you got by executing the script under Step-1. Edit the section  "LIST THE SERVERS FOR SPECIFIC EVENT" with that Instance ID. Save the file with .PS1 extension and then execute it.

Add-PSSnapin citrix.XenApp.Commands

##############################
# LOG FILE TO STORE OUTPUT
##############################
$Log_File="C:\ServerList.txt"
Clear-Content $Log_File

################################
# GET ALL SERVERS IN THE FARM
################################
$Servers=Get-XAServer

####################################################################
# SET THE STARTING DATE. HERE THE DATE STARTS FROM 7 DAYS BACK
####################################################################
$StartTime = (Get-Date).AddDays(-7)

########################################
# LIST THE SERVERS FOR SPECIFIC EVENT
########################################
Get-EventLog -logname System -computername $Servers -After $StartTime | where {$_.InstanceID -eq 2147749413} | Group-Object MachineName | Select-Object Name >> $Log_File

#################
# SENDING MAIL
#################
if ($Log_File -ne $null)
{
echo "Sending email"
$smtpServer = "<SMTP Server Address>"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($Log_File)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

$msg.From = "<From Email>"
$msg.To.Add("<To Email>")
$msg.Subject = "Servers with Event ID 3621"
$msg.Body = "Please see the attached log to check servers with Event ID 3621"
$msg.Attachments.Add($att)

$smtp.Send($msg)
}
else
{
Write-Host "No servers found with that specific Event ID!"
}

Output

Name
------
XENAPP1
XENAPP2
XENAPP3

Wednesday, May 18, 2011

Citrix: Error - Health Monitoring and Recovery test failed

Access Management Console is showing the following error message.




Consequence
Server is not showing in QFARM /LOAD command and users unable to access published applications from that server.

Reason
This is due to the Farm Properties settings. One of the recovery actions is to remove the server from load balancing. Citrix included a range limiter to not remove more thant X% of servers from load balancing basically to prevent a complete farm failure.


































If XML Service Test fails to the meet the required condition, the server will be out of QFARM /LOAD command. If you select XML Service Test and then click on Modify button, you will get the Recovery Option is set to Remove Server from load balancing. This is the defult settings.

Note: You can modify the settings by selecting the Task Name and then set the recovery option by clicking on the Modify button and then select the Recovery action from the drop-down list.



























Steps to add server in the QFARM /LOAD
  1. Open Command Prompt.
  2. Execute the following command:

    ENABLENLB <ServerName>
Notes:
  • HMR is available only on the Windows platform.
     
  • What methodology does HMR use to remove a server from load balancing?
    Citrix makes a call to IMA service to tell the server to remove itself. This is not stored in the Data Store, it is dynamic data. The server in question will then alert the DC that it has been removed.
     
  • Is there a way to setup e-mail alerts or at least upon a failure to have the ability to run a batch or other commands (i.e. scripts, etc.) ?
    The HMR service writes entries to the event log when the tests fail. These are picked up by EdgeSight 5.0 and you can use the EdgeSight alerting capability to set alerts for those events.

Citrix: Logons Hang at for 20 seconds on "Applying Internet Explorer Branding Policy"

When you log on to a Citrix XenApp server, running Windows 2003 with Internet Explorer 7, and there are Active Directory Internet Explorer Maintenance Group Policy settings configured, you experience a 20 second delay at logon.

Note You may experience a similar delay while trying to establish a Terminal Services or a Remote Desktop Services session.










Resolution

A supported hotfix (KB941158) is available from Microsoft to resolve this problem. Download and install that hotfix on the affected server.

Click HERE to download the hotfix.

Click HERE for more information about the hotfix.

After installing the hotfix you have to enable it by modifying registry. To do so, please go through the following procedures.

Caution! This procedure requires you to edit the registry. Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Citrix cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use the Registry Editor at your own risk. Back up the registry before you edit it.
  1. Click Start, Run; type regedit, and then press Enter. Locate and then click the following registry subkey:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl
     
     
  2. On the Edit menu, point to New, and then click Key. Type the following name, and then press Enter:

    FEATURE_PARSING_BRANDING_CMDLINE_FLAGS_KB941158
     
  3. On the Edit menu, point to New, and then click DWORD Value under the key you just created. Type the asterisk symbol (*), and then press Enter.
     
  4. On the Edit menu, click Modify. Type 1, and then click OK.
     
  5. Refresh, and then exit Registry Editor.

Citrix: Event 333 - Application Popup in Windows 2003 System log

Problem
System Log is full with Application Popup (Event 333) error.
































Consequence
You won't be able to lauch any published applications from that server. Sometimes you won't be able to connect to the affected server via RDP also.

Resolution
This issue may occur when the Non Paged Memory or the Paged Pool Memory is temporarily insufficient. The system keeps recording such events until the computer is restarted, or the related hive is unloaded, even though the temporary memory insufficiency stops.

There is a hotfix (WindowsServer2003-KB970054-x86-ENU.exe) available from Microsoft. Download and install that hotfix on the affected server.

Click HERE to download the hotfix.

For more information about event ID 333, click HERE.

Note: To apply this hotfix, the computer must have Windows Server 2003 Service Pack 1 or Service Pack 2 installed.

Check the installation status
After installating hotfix open registry and check the following settings.

Location : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
Name     : RegistryFlushErrorSubside
Type      : REG_DWORD
Value     : 1 or 2

Note: If you set the value of the RegistryFlushErrorSubside entry to 1, the system only records one event 333 when the temporary memory insufficient occurs. If the value is set to 2, the system triggers a Stop error for diagnostic purpose.

After installing the hotfix you have to restart the server.

Citrix: How to change/edit the Welcome message in Citrix web interface









Default Welcome message in Web Interface

Steps

Open Citrix Access Management Console (ACM).
  1. Expand Citrix Resources --> Configuration Tools --> Web Interface.
  2. Select the Web Interface URL.
  3. On the right side click on Customize appearance for user.

     
  4. Click on Content button.

     
  5. Click on Add.

     
  6. Select your preferred language from the Standard language code drop-down list and click Next.

     
  7. Clear Footer Text check box and then click on Next.

     
  8. Enter your customized text in Custome welcome message text box.

     
  9. Click OK.

     
  10. Click OK.

     
  11. Now open the Web Interface. You will see the customized text in Welcome area.

Citrix: How to check the Web Interface version

To check the version of the Web Interface go through the following steps:

  1. On the Citrix server go to C:\Program Files\Citrix\Web Interface
  2. The folder name inside the above path will indicate the version of the Web Interface.
     

Citrix: How to check the installed ICA Client Version

To check the installed ICA Client version go through the following steps.
  1. On the client desktop go to C:\Program Files\Citrix\ICA Client.
  2. Open version.dat file in Notepad to check the version of the ICA client.


Tuesday, May 17, 2011

Citrix: Rejoining Deleted Citrix Server to Farm

If any of the Citrix servers deleted accidentally from Access Management Console you can perform following procedures to rejoin the servers in the existing Farm.

Scenario
I am using following Citrix environment:
  • SQL 2005 Database Server Name - CITRIX
  • Database Autentication - Windows Integrated Authentication
  • Farm Name - MyFarm
  • Servers in the Farm - XENAPP1, XENAPP2, XENAPP3
  • Citrix product version - Presentation Server 4.5 for Windows Server 2003

Problem
I have accedentally removed the server XENAPP3 from the server Farm. Now I want to rejoin the server to the existing Farm.


Resolution
  1. Ensure there are no users logged on. To check that login to the server you want to rejoin and then execute the following command:

    QUSER

    This will show all the users who are currently active on that server. If users are connected do not perform the following steps.
     
  2. Open Command Prompt and run the following command:

    CHFARM

     
  3. Click Yes on the warning message.

     
  4. Select Join an existing farm option and then click on Next.

     
  5. If you have various Zones, clear Use Default Zone Name check box and then enter the Zone name where the server resides.

    If you have only one default Zone, then keep the default setting. In this case I have only one default Zone.

    Click Next to continue.
  6. Select the Database Server Name from the Server drop-down list and then click on Next.

     
  7. Based on your database authentication mode select the authentication. Here I am using Windows Integrated Authentication, so I have selected "With Windows NT authentication using the network login ID". Click Next.
  8. Click on Next. Keep the default setting.

     
  9. Click on Finish. Keep the default settings.

     
  10. Click on Test Data Source to check the connectivity with the Database.

     
  11. Click OK twice to close the connectivity test. The connectivity test should show "TESTS COMPLETED SUCCESSFULLY".

     
  12. Enter the credentials to connect to the database and then click Next.

     
  13. I am using IMA Encryption. Select the encrypted key by clicking on the Browse button and then click on Next.

     
  14. You can specify License Server name and License Server Port seperately. If you want to inherit the Global Farm settings then select "Use the global farm settings for the license server.". Click Next.

     
  15. Confirm the name of the Server Farm and then click on Finish.


    IMPORTANT: When "Joining an Existing Farm" if the Farm Name is NOT displayed in this "grayed out" field on the last screen. DO NOT proceed. The credentials you entered for IMA to connect to the Data Store are invalid. Go back and confirm the user account and password are correct.
  16. Click on Yes if you get IMA service warning.

     
  17. It will try to start and then stop the IMA service. Click on Yes if you get the following warning.

     
  18. On successfully adding the server to the existing Farm, you will get the following confirmation message. Click OK.

     
  19. Now if you check the server Farm, you will get the deleted server added to the existing Farm.

Citrix: Must Know - Some Important Points about Citrix / XenApp

Farm
A Farm is a group of Citrix servers which provides published applications to all users that can be managed as a unit, enabling the administrator to configure features and settings for the entire farm rather than configuring each server individually. All the servers in the farm share a single data store.

A server farm is a grouping of servers running Citrix Presentation Server that can be manage as a unit, similar in principle to a network domain. When designing server farms, keep in mind the goal of providing users with the fastest possible application access while achieving the degree of centralized administration and network security that you need.

Data Store
This is the place where all the static information are stored. The data store provides a repository of persistent information about the farm (Farm configuration information, Published Application configurations, Server configurations, Static policy configuration, XenApp administrator accounts, and Printer configurations) that all servers can refer.


The data store is the central repository where almost the entire Citrix implementation is invested. The Administrators of the farm, the license server to point to, the whole farm configuration, the published applications, all their properties, the security of who gets access to what, the custom load evaluators, custom policies, configured printers and print drivers, all this is stored in the central repository called the data store.


Data Collector
Data Collector stores all the dynamic information like session, load and published applications in the servers in their zones and communicates the zone information to the Data Collectors in other zones in the farm Data collector is a Citrix Presentation Server whose IMA service takes on the additional role of tracking all of the dynamic information of other Presentation Servers. This information is stored in memory and called the “dynamic store”. The data store is a database on disk. The dynamic store is information stored in memory.

To look the contents of the in-memory dynamic store on the data collector, use “queryds” command. QueryDS can be found in the "support\debug" folder of your Presentation Server installation source files. To determine which server is acting as the data collector in the zone run "query farm /zone" from the command line.


LHC
The IMA service running on each Presentation Server downloads the information it needs from the central data store into a local MDB database called the local host cache, or “LHC.” (The location of the local host cache is specified via a DSN referenced in the registry of the Presentation Server, at HKLM\SOFTWARE\Citrix\IMA\LHCDatasource\DataSourceName. By default this is a file called “Imalhc.dsn” and is stored in the same place as MF20.dsn.)

Each Presentation Server is smart enough to only download information from the data store that is relevant to it, meaning that the local host cache is unique for every server. Citrix created the local host cache for two reasons:

1. Permits a server to function in the absence of datastore connectivity.
2. Improves performance by caching information used by ICA Clients for enumeration and application resolution.

The LHC is an Access database (Imalhc.mdb) stored default in the path"<ProgramFiles>\Citrix\Independent Management Architecture" folder.

LHC contained the following information:
1. All servers in the farm, and their basic information.
2. All applications published within the farm and their properties.
3. All Windows network domain trust relationships within the farm.
4. All information specific to itself. (product code, SNMP settings, licensing information)

The LHC is critical in a CPS environment. In fact, it's the exclusive interface of the data store to the local server. The local server's IMA service only interacts with the LHC. It never contacts the central data store except when it's updating the LHC. If the server loses its connection to the central data store, there's no limit to how long it will continue to function. (In MetaFrame XP, this is limited to 48 or 96 hours, but that was because the data store also store license information.) But today, the server can run forever from the LHC and won't even skip a beat if the central connection is lost. In fact now you can even reboot the server when the central data store is down, and the IMA service will start from the LHC with out any problem. (Older versions of MetaFrame required a registry modification to start the IMA service from the LHC.

The LHC file is always in use when IMA is running, so it's not possible to delete it or anything. In theory it's possible that this file could become corrupted, and if this happens I guess all sorts of weird things could happen to your server. If you think this is the case in your environment, you can stop the IMA service and run the command "dsmaint recreatelhc" to recreate the local host cache file, although honestly I don't think this fixes anything very often. Local Host Cache is synchronised with the Data Store by the Zone Data Collector for every 30 minutes and it can also be configured through registry.

Restarting Servers at Scheduled Times
To optimize performance, you can restart a server automatically at specified intervals by creating a restart schedule.


Restart schedules are based on the local time for each server to which they apply. This means that if you apply a schedule to servers that are located in more than one time zone, the restarts do not happen simultaneously; each server is restarted at the selected time in its own time zone.

When the Citrix Independent Management Architecture service starts after a restart, it establishes a connection to the data store and updates the local host cache. This update can vary from a few hundred kilobytes of data to several megabytes of data, depending on the size and configuration of the server farm.

To reduce the load on the data store and to reduce the IMA service start time, Citrix recommends maintaining restart groups of no more than 100 servers. In large server farms with hundreds of servers, or when the database hardware is not sufficient, restart servers in groups of approximately 50, with at least 10 minute intervals between groups.