Dynamic tokens
You can use dynamic tokens in any Workspace Environment Management actions to make them more powerful.
You can use dynamic tokens in the following fields:
-
Group Policy settings
- With Action set to Delete value: Value
- With Action set to Set value and Type set to REG_SZ: Value, Data
- With Action set to Set value and Type set to REG_EXPAND_SZ: Value, Data
- With Action set to Set value and Type set to REG_MULTI_SZ: Value, Data
Note:
Group Policy settings come in two types: Machine settings and user settings. For machine settings, some dynamic tokens are not supported. See Dynamic token support for Group Policy settings.
Dynamic token support for Group Policy settings
Using dynamic tokens in Group Policy settings allows for more adaptable policy configuration in different environments, reduces manual configuration, and simplifies policy management.
Group Policy settings come in two types:
- Machine settings. Those settings apply only to machines regardless of who logs on to them.
- User settings. Those settings apply only to users regardless of which machine they log on to.
All dynamic tokens are supported for Group Policy settings. The following ones are not supported for machine settings.
-
Hashtags
- ##FullUserName##
- ##UserInitials##
- ##ClientName##
- ##ClientIPAddress##
- ##UserLDAPPath##
- ##ClientRemoteOS##
- ADAttribute
- [ADAttribute:attrName]
- [UserParentOU: level]
- Registries under HKCU
Applications
- With Installation application as the application type: Command Line, Working Directory, and Parameters
- With File/Folder as the application type: Target
- With URL as the application type: Shortcut URL
- Icon File
Printers
- Target Path
Network drives
- Target Path and Display Name
Virtual drives
- Target Path
Registries
- Target path, Target name, and Target value
Note:
The Target value field does not support environment variable expansion. If you use environment variables, they do not work as expected.
Environment variables
- Variable value
Ports
- Port Target
Ini files
- Target path, Target section, Target value name, and Target value
Note:
The Target section, Target value name, and Target value fields do not support environment variable expansion. If you use environment variables, they do not work as expected.
External tasks
- Path and Arguments
File system operations
- Source Path and Target Path
Certain filter conditions
- Example: With Active Directory Attribute Match* as the condition type: **Tested Active Directory Attribute and Matching Result
Note:
For a complete list of supported fields for filter conditions, see Supportability matrix for filter conditions.
String operations
Sometimes you need to manipulate strings within a script to map drives or launch applications. The following string operations are accepted by the Workspace Environment Management agent:
Modal | Description | Example |
---|---|---|
#Left(string,length)# | Returns the specified number of characters on the left. |
#Left(abcdef,2)# returns ab
|
#Right(string,length)# | Returns the specified number of characters on the right. |
#Right(abcdef,2)# returns ef
|
#Truncate(string,length)# | If the length of the string is less than or equal to the specified length, returns the entire string. If the length of the string is greater than the specified length, returns the specified number of characters on the left. |
#Truncate(abcdef,3)# returns abc
|
&Trim(string)& | Removes all leading and trailing blank spaces of the string. |
&Trim( a b c )& returns a b c
|
&RemoveSpaces(string)& | Removes all blank spaces of the string. |
&RemoveSpaces( a b c )& returns abc
|
&Expand(string)& | If the string contains an environment variable that is enclosed with \%, expands the variable. |
&Expand(%userprofile%\destop)& returns C:\Users\Jill\desktop
|
$Split(string, splitter],index)$ | Splits the string into substrings based on the splitter that is enclosed with [] and returns the indexed substring. |
$Split(abc-def-hij,[-],2)$ returns hij
|
#Mid(string,startindex)# | Starts at the specified index in the string and returns all characters after it. |
#Mid(abcdef,2)# returns cdef
|
!Mid(string,startindex,length)! | Starts at the specified index in the string and returns the specified number of characters. |
!Mid(abcdef,1,2)! returns bc
|
!Substring(string,startindex,length)! | Starts at the specified index in the string and returns the specified number of characters. |
!Substring(abcdef,1,2)! returns bc
|
#Mod(string,length)# | Divides the string by the length and returns the remainder. The string must be able to be converted to an integer. |
#Mod(7,3)# returns 1
|
Note:
- String operations are also supported with hashtags and Active Directory attributes. For example:
#Left([ADAttribute:NAME],2)#
where the name attribute of the current domain user isAdministrator
returnsAd
, and$Split(##ClientIPAddress##,[\.],2)$
returns157
.!Mid(string,startindex,length)!
and!Substring(string,startindex,length)!
operations are always performed last.
Hashtags
Hash-tags are a replacement feature widely used in the processing of Workspace Environment Management items. The following example illustrates how you use hash-tags:
To write to an .ini file, you can use %UserName% in the .ini file’s path and Workspace Environment Management processes it and expands the final directory. However, assessing the value which Workspace Environment Management writes in the .ini itself is more complicated: you may want to write %UserName% literally, or write the expanded value.
To increase flexibility, ##UserName## exists as a hash-tag, so that using %UserName% for a value writes it literally and ##UserName## writes the expanded value.
See the following table for examples:
Modal | Description | Example |
---|---|---|
##UserName## | Returns the expanded environment variable “%username%” | Jill |
##UserProfile## | Returns the expanded environment variable “%userprofile%” | C:\Users\Jill |
##FullUserName## | Returns the user’s full name in Active Directory | Jill Chou |
##UserInitials## | Returns the user name initials in Active Directory | JC |
##UserAppData## | Returns the actual path of the special folder - RoamingAppData | C:\Users\Jill\AppData\Roaming |
##UserPersonal## | Returns the actual path of the special folder - Documents | C:\Users\Jill\Documents |
##UserDocuments## | Returns the actual path of the special folder - Documents | C:\Users\Jill\Documents |
##UserDesktop## | Returns the actual path of the special folder - Desktop | C:\Users\Jill\Desktop |
##UserFavorites## | Returns the actual path of the special folder - Favorites | C:\Users\Jill\Favorites |
##UserTemplates## | Returns the actual path of the special folder - Templates | C:\Users\Jill\AppData\Roaming\Microsoft\Windows\Templates |
##UserStartMenu## | Returns the actual path of the special folder - StartMenu | C:\Users\Jill\AppData\Roaming\Microsoft\Windows\Start Menu |
##UserStartMenuPrograms## | Returns the actual path of the special folder - Programs | C:\Users\Jill\AppData\Roaming\Microsoft\Windows\Start Menu\Programs |
##UserLocalAppData## | Returns the actual path of the special folder - LocalAppData | C:\Users\Jill\AppData\Local |
##UserMusic## | Returns the actual path of the special folder - Music | C:\Users\Jill\Music |
##UserPictures## | Returns the actual path of the special folder - Pictures | C:\Users\Jill\Pictures |
##UserVideos## | Returns the actual path of the special folder - Videos | C:\Users\Jill\Videos |
##UserDownloads## | Returns the actual path of the special folder - Downloads | C:\Users\Jill\Downloads |
##UserLinks## | Returns the actual path of the special folder - Links | C:\Users\Jill\Links |
##UserContacts## | Returns the actual path of the special folder - Contacts | C:\Users\Jill\Contacts |
##UserSearches## | Returns the actual path of the special folder - SavedSearches | C:\Users\Jill\Searches |
##commonprograms## | Returns the actual path of the special folder - CommonPrograms | C:\ProgramData\Microsoft\Windows\Start Menu\Programs |
##ComputerName## | Returns the machine’s name | WIN10EN-LR3B66L |
##ClientName## | Returns the client machine’s name | W2K16ST-5IS28JP |
##ClientIPAddress## | Returns the client machine’s IP address | 10.150.153.138 |
##IpAddress## | Returns the machine’s IP address | 10.150.153.213 |
##ADSite## | Returns the Active Directory site that the machine is a member of | NKG |
##DefaultRegValue## | - | Always string.Empty |
##UserLDAPPath## | Returns the current user’s distinguished name | CN=Jill Chou,OU=User Accounts,OU=APAC,DC=citrite,DC=net |
##VUEMAgentFolder## | Returns the agent folder | C:\Program Files (x86)\Citrix\Workspace Environment Management Agent |
##RDSSessionID## | Returns the remote desktop session ID | 2 |
##RDSSessionName## | Returns the remote desktop session name | RDP-Tcp#72 |
##ClientRemoteOS## | Returns the operating system of the machine used to connect to the virtual desktop | Windows |
##ClientOSInfos## | Returns the machine’s OS information | Windows 10 Enterprise 64-bit |
Hash-tag ##UserScreenCaptureComment## is implemented for use in specific parts of the product. This tag can be included in the Email Template under Advanced Settings > UI Agent Personalization > Helpdesk Options. When included, users are presented with a comment field located below the screen capture in the agent screen capture utility. The comment is included in the support email at the location at which you placed the tag in the email template.
Active Directory attributes
To work with Active Directory attributes, WEM replaces the [ADAttribute:attrName] value with the related Active Directory attribute. [ADAttribute:attrName] is the dynamic token for any Active Directory attributes. There is a related filter that checks the value of the specified attributes.
For user organizational unit (OU) structures, WEM replaces the [UserParentOU:level] value with the related Active Directory OU name. The Active Directory path is the complete user path (LDAP) in Active Directory and [UserParentOU:level] is a subset of it.
For example, suppose you want to build a network drive for an OU to which the users belong. You can use the dynamic token [UserParentOU:level] in the network drive path to resolve the users’ OU dynamically. There are two ways to use the dynamic token:
- Use the [UserParentOU:level] dynamic token directly in the network drive path. For example, you can use the following path:
\\Server\Share\[UserParentOU:0]\
. - Set an environment variable called OU, and then set its value to [UserParentOU:0]. You can then map the drive as
\\Server\Share\%OU%\
.
Note:
- You can substitute the digit “0” with the number that corresponds to the level you want to reach in the OU structure.
- You can append variables to the path. To do this, ensure that you have an exact folder structure that matches your OU layout.
You can also use Active Directory attributes for filtering purposes. On the Administration > Filters > Conditions > Filter Condition List tab, you can open the New Filter Condition window after you click Add. In the New Filter Condition window, you can see the following four filter condition types associated with Active Directory attributes:
- Active Directory Attribute Match
- Active Directory Group Match
- Active Directory Path Match
- Active Directory Site Match
For Active Directory Attribute Match, the dynamic token is [ADAttribute:attrName]. There is no dynamic token available for Active Directory Group Match because that condition type is used to check a group membership. For Active Directory Path Match, the dynamic token for the full LDAP path is ##UserLDAPPath##. For Active Directory Site Match, the dynamic token is ##ADSite##.
See the following table for examples:
Modal | Description | Example |
---|---|---|
[ADAttribute:attrName] | Returns the specified attribute of the domain user |
[ADAttribute:name] returns Administrator
|
[PrinterAttribute:printername|attrName] | Returns the specified attribute of the specified domain printer | [PrinterAttribute:printer1|name] returns printer1 |
[UserParentOU: level] | Returns the specified level of the current user’s parent OU |
[UserParentOU:1] in CN=Jill Chou,OU=User Accounts,OU=APAC,DC=citrite,DC=net returns APAC
|
Registries
To work with a registry, WEM replaces the [RegistryValue:<Registry path>]
value with the related registry value. For example, you can specify the following value:
- [RegistryValue:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Norskale\Agent Host\AgentLocation]
XML files
To work with an XML file, WEM replaces the [GetXmlValue:<XML path>|<tag name>]
value with the specific tag value in the XML file. The XML path can be an actual path or an environment variable that resolves to a path. You must enclose the environment variable with %. For example, you can specify the following value:
- [GetXmlValue:C:\citrix\test.xml|summary] or
- [GetXmlValue:%xmlpath%|summary]
INI files
To work with an .ini file, WEM replaces the [GetIniValue:<INI path>|<section name in the .ini file>|<key name in the .ini.file>]
with the key value. The INI path can be an actual path or an environment variable that resolves to a path. You must enclose the environment variable with %. For example, you can specify the following value:
- [GetIniValue:C:\citrix\test.ini|PLD_POOL_LIC_NODE_0_0|LicExpTime] or
- [GetIniValue:%inipath%|PLD_POOL_LIC_NODE_0_0|LicExpTime]
More information
Supportability matrix for filter conditions
The following table lists all condition types whose tested value or matching result supports dynamic tokens.
Condition type | Tested value | Matching result |
---|---|---|
ComputerName Match | - | Yes |
ClientName Match | - | Yes |
Environment Variable Match | No | Yes |
Registry Value Match | Yes | Yes |
WMI Query Result Match | - | Yes |
XenApp Farm Name Match | - | Yes |
XenApp Zone Name Match | - | Yes |
XenDesktop Farm Name Match | - | Yes |
XenDesktop Desktop Group Name Match | - | Yes |
Active Directory Attribute Match | Yes | Yes |
Name or Value is in List | Yes | Yes |
No ComputerName Match | - | Yes |
No ClientName Match | - | Yes |
No Environment Variable Match | No | Yes |
No Registry Value Match | Yes | Yes |
No WMI Query result Match | - | Yes |
No XenApp Farm Name Match | - | Yes |
No XenApp Zone Name Match | - | Yes |
No XenDesktop Farm Name Match | - | Yes |
No XenDesktop Desktop Group Name Match | - | Yes |
No Active Directory Attribute Match | Yes | Yes |
Name or Value is not in List | Yes | Yes |
Dynamic Value Match | Yes | Yes |
No Dynamic Value Match | Yes | Yes |
File Version Match | Yes | Yes |
No File Version Match | Yes | Yes |
Published Resource Name | - | Yes |
Name is in List | Yes | Yes |
Name is not in List | Yes | Yes |
File/Folder exists | - | Yes |
File/Folder does not exist | - | Yes |
In this article
- Dynamic token support for Group Policy settings
- Applications
- Printers
- Network drives
- Virtual drives
- Registries
- Environment variables
- Ports
- Ini files
- External tasks
- File system operations
- Certain filter conditions
- String operations
- Hashtags
- Active Directory attributes
- Registries
- XML files
- INI files
- More information