Citrix Commands
Citrix Commands
html
The following list of command line utilities is available on a Citrix XenApp 6 server for
administration:
Command: Description
altaddr: Specify server alternate IP address.
app: Run application execution shell.
auditlog: Generate server logon/logoff reports.
change: client Change client device mapping.
ctxkeytool: Generate farm key for IMA encryption.
ctxxmlss: Change the Citrix XML Service port number.
dscheck: Validate the integrity of the server farm data store.
dsmaint: Maintain the server farm's data store.
enablelb: Enable load balancing for servers that fail health monitoring tests.
icaport: Configure TCP/IP port number used by the ICA protocol on the server.
imaport: Change IMA ports.
query: View information about server farms, processes, ICA sessions, and users. The query
command uses a set of extra nouns to identify which XenApp component should be queried for
data. Those nouns are: query farm, query process, query session, query termserver, and query
user.
These command line utilities are available on each server, but this version of Citrix XenApp leans
heavily on Windows PowerShell for many command line functions. PowerShell exposure for
Citrix XenApp is found in the XenApp 6 PowerShell SDK, which can be downloaded from Citrix.
4.5. Useful Citrix Commands
How do I recreate the local host cache?
dsmaint recreatelhc
How do I find all servers in the farm and see which one is the data collector?
query farm
How do I check the database consistency, and fix if required?
dscheck /full servers /clean
dscheck /full apps /clean
How do I join a server to a farm?
chfarm /joinfarm
How do I find the data store in Citrix?
Open the file located at C:\Program Files\Citrix\Independent Management Architecture\MF20.dsn
Check for the line that reads SERVER=TheSQLServerName. If the farm uses an Access DB it will state
DBQ=PathToMDB.
While managing your Citrix XenApp 6 farm from the comfort of the Citrix
Delivery Services Console GUI tool is a very powerful thing, you should know
that XenApp 6 also has a subset of command-line tools that are at your
disposal and can help with advanced farm management and troubleshooting:
1. Altaddr: If you're a Citrix old timer, you probably remember using this tool
before secure gateway was available, in order to extend the published
applications to users outside the secure network. In essence, what Altaddr
allows you to do is give your XenApp server an alternate IP address.
Traditionally this was an outside facing public IP address or some kind of a
NAT. Of course, the down side is if you have 100 XenApp servers, you would
need 100 public IP addresses. Altaddr is not in use or popular anymore, but it
is still there if you have the distinct situation where it makes sense.
2. App: Typically used for scripting or customizing an application's behavior.
You can use App in your scripts to control the application's environment or to
satisfy its prerequisites before the application runs.
3. Auditlog: A handy utility that, for the most part, dumps the security event
log from Windows and allows you to pipe that log into a text file. You can use
the output to audit who logged in or out of the server and when. This could
come in handy if you are troubleshooting, for example, if your print service
crashes; you can see who logged in during that time and if they are mapping a
bad driver, etc.
4. Change client: Allows you to change the client device mappings in an ICA
session, LOT, COM, USB mappings. etc.
5. Ctxkeytool: You can use this utility to generate an encryption key that can
be used when enabling IMA encrypted communication in the Citrix farm.
6. Ctxxmlss: This handy little utility allows you to modify the XML port on the
XenApp servers should you need to change that port for any reason.
7. Dscheck: I use this tool frequently to check for consistency on the Citrix
IMA data store. It is particularly handy in conjunction with the /clean switch,
which you would use to clear out any inconsistencies in the database.
8. Dsmaint: All interaction with your data store can be manipulated using this
tool. For example, if you want to change data store database servers, you can
use Dsmaint to do so. You can also use it to verify the local host cache on the
XenApp server. The Local Host Cache or LHC is a subset of the data store
database that runs on each XenApp server. Sometimes, as a troubleshooting
step, you may want to verify the accuracy of that data or even refresh it
altogether.
9. Enablelb: This utility restores XenApp servers into the load balancing mix
after they have failed Citrix health monitoring tests.
10. Icaport: Here's a too that allows you to change the default port that the
ICA protocol typically runs on.
11. Imaport: allows you to change the default port that the IMA protocol runs
on
12. Query: Arguably the most useful command-line tool, I use the query
command for troubleshooting, for verifying load on the server, for just about
anything administration related. If I need to know, I always start with the query
command. It has a subset of values:
1. Query Farm or QFARM returns information on the XenApp servers in
server
All these tools are available to you with the default installation of XenApp 6.
However, as you can see from the list above, the number of Citrix XenApp 6
command-line tools has been shrinking with each new version and that is not
because of insufficient development. Instead, it's because Citrix is kind of
following the Microsoft lead and porting most of its command-line tools to
PowerShell. Event so, XenApp 6 has a very rich PowerShell footprint, wihich I
plan to explore more in future blogs.
Scenario 1
Summary
In this scenario we will migrate a data store located on server XA03 to a new
database located on SQL Express installed on server XD01. To perform a
migration we will use dsmaint command. SQL management studio will be used
only in order to create a empty database on new SQL server and assign user
name and permission to the database.
Action plan is the following:
Take a backup of your exisiting datastore.
Migrate the content of data store to a new database.
Create empty database on target server
Create new dsn file pointing to the new SQL server
Migrate the content of data store to a new database.
Run dsmaint config command
Reconfigure remainig servers
On remaining servers create a new file dsn pointing to the new SQL server.
Stop IMA Service
Run dsmaint config command
Recreate local host cache
Start IMA Service
Take a backup of your exisiting datastore.
When XenApp Server Role Manager is used to install SQL Express a standard
configuration is used and database engine is configured with the following
settings:
SQL Instance name: CITRIX_METAFRAME
Database location folder: C:\Program Files (x86)\Citrix\Independent Management
Architecture
Database name: MF20.mdf
It is a best practice to always backup the XenApp database before performing
any operation on data store. To preform the backup we will use dsmain
command. The XenApp Server DSMAINT Reference contains syntax and use
details.
Important note: In many posts or articles you can find an information that
dsmaint command can be used to backup only data store stored in MS Access
database. Please remember that starting from XenApp 6 MS Access is no longer
supported and dsmaint backup command can be used to perform the backup of
data store hosted on SQL Server Express.
From the command prompt the following command is executed:
dsmaint backup c:\backup
The result is shown below:
The command dsmaint with parameter backup makes a copy of the MF20.mdf
SQL Server Express data store to the specified location. Please note that
dsmaint backup must be run on the XenApp 6.x server hosting the SQL Server
Express data store. This command will not work when you try to backup
database located on remote server hosting SQL Server Express and will not
return and error message as it is shown below:
Click OK and the new data store database is created and ready for use as shown
below:
On the XenApp server hosting the SQL Server Express data store, a new Data
Source Name (DSN) must be created for the new SQL database.
Go to Start -> Administrative Tools -> Data Sources (ODBC) and navigate to File
DSN tab. Change the Look in to C:\Program Files (x86)\Citrix\Independent
Management Architecture as shown below:
Click Add button to create a new dsn file. New dsn file must be pleaced
in C:\Program Files (x86)\Citrix\Independent Management Architecture folder.
Click Next and Finish and configure the connection parameters as description
and server name.
Click Next. If everything is configured correctly you will be switched to the next
page of the connfiguration wizard as it is shown below
To initiate the migration of data store open the command line window
In the next step IMA service needs to be configured to connect to the new data
store. Open the command prompt and stop IMA service:
Type dsmaint recreatelhc and press Enter. This command will recreate Local Host
Cache file.
At this stage the migration of the server hosting data store is completed. If your
XenApp farm consist of more than 1 server all remaining servers must be
configured to connect to new data store.
Reconfigure remainig server
On the server migrated in the previous step open folder C:\Program Files
(x86)\Citrix\Independent Management Architecture and edit new dsn file in my
case fileXA65Small.dsn
Remove the computer name from the WSID line. The WSID line is not used.
Copy modified XA65Small.dsn to all farms member servers into C:\Program Files
(x86)\Citrix\Independent Management Architecture folder and follow update
steps.
Open the command prompt and stop IMA service:
Type dsmaint recreatelhc and press Enter. This command will recreate Local Host
Cache file.
Scenario 2
Summary
In this scenario we will migrate a data store for farm XA_65_LAB located in
database XA65LAB on server XD01 into new database XA65LabNew located on
the same server. Farm XA_65_LAB consist of 2 server XA01 and XA 02. Both
XenApp servers are configured with the Controller and Session-host mode
enabled.
Action plan is the following:
Take a backup of your exisiting datastore.
Restore content of data store to a new database.
Create empty database on target server
Restore a backup to newly created database
Create new dsn file pointing to the new database.
Run dsmaint config command
Reconfigure remainig servers
On remaining server create a new file dsn pointing to the new database.
Stop IMA Service
Run dsmaint config command
Recreate local host cache
Click Add button and select Backup folder and type name for backup file.
Click OK
Click OK and when new database is created and right-click new database
XA65LabNew and seclect Task -> Restore -> Database
Click Add and navigate to the folder where data store backup was saved and
select latest backup file.
Click OK
Select Files in the left pane and in Restore As select database files for new
database. Note: This setp is very important otherwise orginal database files will
be overwritten !!!!
Click Options in the left pane and select Overwrite the existing database
Press OK
On server XA01 goto Start -> Administrative Tools -> Data Sources (ODBC) and
navigate to File DSN tab. Change the Look in to C:\Program Files
(x86)\Citrix\Independent Management Architecture as shown below:
Click Add button to create a new dsn file. New dsn file must be pleaced
in C:\Program Files (x86)\Citrix\Independent Management Architecture folder.
Click Next and Finish and configure the connection parameters as description
and server name.
Click Next. If everything is configured correctly you will be switched to the next
page of the connfiguration wizard as it is shown below
When connection is established click Next. Change the default database to the
database which will be used as a new data store
In the next step IMA service needs to be configured to connect to the new data
store. Open the command prompt and stop IMA service:
Type dsmaint recreatelhc and press Enter. This command will recreate Local Host
Cache file.
At this stage the migration of the server hosting data store is completed. Server
XA02 must be configured to connect to new data store.
Remove the computer name from the WSID line. The WSID line is not used.
Type dsmaint recreatelhc and press Enter. This command will recreate Local Host
Cache file.
Scenario 3
Summary
In this scenario we will migrate a data store for farm XA_65_LAB located in
database XA65LabNew on server XD01 into new database XA65DataStore
located on the same server. Farm XA_65_LAB consist of 2 server XA01 and XA
02. Both XenApp servers are configured with the Controller and Session-host
mode enabled.
Action plan is the following:
Take a backup of your exisiting datastore.
Restore content of data store to a new database.
Click Create New DSN to create new connection file. ODBC window will be open
Open File DSN tab and create new dsn file using procedure described in scenario
2. I created XA65DataStore.dsn dsn file.
Enter valid credentials and press Run to execute dsmaint config command.
Wait for
confirmation popup
QFARM /APP
QFARM /APP <appname> The QFARM command may not return any results when a custom
administrator runs the following queries: QFARM /DISC
QFARM /LOAD
QFARM /ZONELOAD
Presentation Server is part of a disaster plan that fails over to an alternate location
User-specific backend data is located in other locations than the main data center
4) How big a zone can get?
Its just a matter of looking at the traffic patterns. For instance, do you want one single data
collector updating 1000 servers whenever you make a change to the environment (one zone), or
do you want two data collectors to each update only 500 servers (one zone).
5) When would you suggest creating new farm?
When you want the member servers talk to different datastore like a test environment;
6) What is a Data Store?
This is the place where all the static information are stored. Farm configuration information,
Published Application configurations, Server configurations, Static policy configuration, XenApp
administrator accounts, and Printer configurations) that all servers can refer.
7) How to migrate datastore database from SQL2000 to SQL2005 OR How to recover
datastore database?
Restore the DB to new server
Change mf20.dsn on all servers starting with data collectors
Restart IMA service on all servers
8) How to find out the datastore database server name?
Examine the DSN file which contains the connection details to the database.
C:\Program Files\Citrix\Independent Management Architecture\MF20.dsn
The following is an example of an MF20.dsn file from a server connecting to a remote SQL
Server instance:
[ODBC]
DRIVER=SQL Server
UID=useraccount
Address=SqlServer,1433
Network=
DATABASE=farmdb
WSID=
APP=Citrix IMA
SERVER=SqlServer
9) How to verify Datastore DB connectivity?
To determine if a server is communicating regularly with the data store, check the following
registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\CITRIX\IMA\DataStoreFailureTime
If the value is all zeros, the MetaFrame server is communicating with the data store.
10) How often does the member servers check datastore database?
By default, every 30 minutes.
11) what happens if datastore connectivity is lost?
If the server loses its connection to the central data store, theres 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
wont 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.)
12) How will you remove Citrix server from the farm?
If the server is unresponsive, remove it by right click on server in the console.
For functional server, remove it from add/remove programs
use CHFARM command
13) How will you remove citrix server from the datastore DB?
When citrix is uninstalled from the server, it cleans the entry from data store database.
Additionally you can run this command to remove the entry from Datastore DB.
DSCHECK /servername
Existing users wont be impacted, but no new users will be able to access the applications
published from the server.
23) What is Citrix XML service?
The Citrix XML server is a component of Citrix XenApp and XenDesktop thats used to
enumerates available resources and provide secure tickets for users that to use the WebInterface
or CloudGateway.
XML service has two functions:
Communicating with the XenApp farm / XenDesktop zones; the XML broker
Generating and validating secure ticket to authorize users, the Secure Ticket Authority
(STA)
24) How to change the port used by XML service?
By default XML service uses port 80. But citrix recommends using port 8080 inorder to avoid
conflicts with IIS.
To change the port used by XML service:
In XenApp 6 and above this can be changed via Citrix policies.
In Earlier versions Use the ctxxmlss command-line utility. This can be done by unloading the
Citrix XML Service with /u, changing the port with /r<port number> and restarting the XML
service.
ctxxmlss /u
ctxxmlss /r8080
An alternative method is by changing the port in the registry (and restart the Citrix XML service
after changing).
Key :HKLM\System\CurrentControlSet\Services\CtxHTTP
Value: TCP Port
The value is listed in hex, you need to change the view to decimal.
25) Explain Citrix Load Levels?
The following are explanations of the load levels:
Session Lingering
Session Pre-Launch
App Center
Load Evaluators assigned to Worker Groups or OUs instead of individual servers
Datastore and Zone information configured via GPO
Sesssion Only and Controller roles
Desktop Director web console can manage XenApp sessions
MultiStream ICA ica traffic can be split into four separate TCP streams if required
Log On control feauture to drain users.
29) What would happen if you stop the IMA service on a server?
Existing users on the server will not face any issues, but no new user connections to the server
would be allowed.
In Script Name , type the path to the script, or click Browse to search for the
script file in the Netlogon shared folder on the domain controller.
In Script Parameters , type any parameters that you want, the same way as you
would type them on the command line. For example, if your script includes
parameters called //logo (display banner) and //I (interactive mode), type //logo //I .
In the Logon Properties dialog box, specify the options that you want:
Logon Scripts for <Group Policy object> : Lists all the scripts that currently are
assigned to the selected Group Policy object (GPO). If you assign multiple scripts, the
scripts are processed in the order that you specify. To move a script up in the list,
click it and then click Up . To move a script down in the list, click it and then click
Down .
Add : Opens the Add a Script dialog box, where you can specify any additional
scripts to use.
Edit : Opens the Edit Script dialog box, where you can modify script information,
such as name and parameters.
Remove : Removes the selected script from the Logon Scripts list.
Show Files : Displays the script files that are stored in the selected GPO.
Additional considerations
To complete this procedure, you must have Edit setting permission to edit a GPO. By
default, members of the Domain Administrators security group, the Enterprise
Administrators security group, or the Group Policy Creator Owners security group have Edit
setting permission to edit a GPO.
Setting logon scripts to run synchronously may cause the logon process to run slowly.
Logon scripts are run as User, not Administrator, and their rights are limited accordingly.