Citrix Virtual Apps and Desktops – Commonly used PowerShell commands

Here’s a cheat sheet with some common commands used in Citrix Virtual Apps and Desktop deployments, along with their explanations:

Remember to be careful with the SET, Remove, New, Add PowerShell commands as they can make undesirable changes if you don’t know what you are doing. Always start with a Get 🙂

Of course, start with the below command to load all the Citrix PS modules first


asnp citrix*

I would suggest you run the below commands as per your requirement and then select the specific parameters to fine tune the results.

For eg, if I need to find all the machines in a CVAD (XenApp) farm, I would just run the command Get-BrokerMachine and then look at the specific information that I want to filter the results on. The below filter would come in very handy when you want to look for specific info.

Get-BrokerMachine | Select-Object -Property MachineName

Now if you want to also see the Machine catalog names alongside the VM name, then try the below

Get-BrokerMachine | Select-Object -Property MachineName, CatalogName

You can also pipe the results into a CSV or text file depending on your needs. For that,

Get-BrokerMachine | Select-Object -Property MachineName, CatalogName | Export-Csv C:\temp\Machinename.csv

This should get you started. Hope this helps!

CommandExplanation
Broker PowerShell commands
Get-BrokerApplicationReturns a list of published applications.
Get-BrokerCatalogReturns a list of catalogs containing desktops.
Get-BrokerDesktopReturns a list of desktops.
Get-BrokerMachineReturns a list of machines in the site.
Get-BrokerSiteReturns the configuration for the site.
New-BrokerDesktopGroupCreates a new desktop group.
New-BrokerIconCreates a new published application icon.
New-BrokerMachineCatalogCreates a new machine catalog.
Remove-BrokerApplicationRemoves a published application.
Remove-BrokerDesktopRemoves a desktop.
Remove-BrokerMachineRemoves a machine.
Set-BrokerAccessPolicyRuleModifies an access policy rule.
Set-BrokerCatalogPowerActionConfigures power management settings for a catalog.
Set-BrokerDesktopGroupModifies a desktop group.
Set-BrokerIconModifies a published application icon.
Set-BrokerMachineModifies a machine.
Citrix Studio commands
Add-BrokerEntitlementPolicyRuleAdds an entitlement policy rule.
Add-BrokerMachineAdds a machine to the site.
Add-BrokerTagAdds a tag to a machine or catalog.
Export-BrokerDesktopGroupExports a desktop group configuration to a file.
Get-BrokerEntitlementPolicyRuleReturns a list of entitlement policy rules.
Get-BrokerEntitlementPolicyRuleFilterReturns a list of entitlement policy rule filters.
Get-BrokerHostingPowerActionReturns a list of power management settings for machines.
Get-BrokerMachineConfigurationReturns the configuration for a machine.
Import-BrokerDesktopGroupImports a desktop group configuration from a file.
Remove-BrokerEntitlementPolicyRuleRemoves an entitlement policy rule.
Remove-BrokerMachineTagRemoves a tag from a machine or catalog.
Set-BrokerDesktopModifies a desktop.
Set-BrokerEntitlementPolicyRuleModifies an entitlement policy rule.
Set-BrokerTagModifies a tag.
Test-BrokerCatalogTests the connection to a catalog.

Let’s look at some PowerShell commands to manage DDCs and Storefronts

CommandExplanation
Delivery Controller commands
Get-BrokerControllerReturns the configuration for a Delivery Controller.
Set-BrokerControllerModifies the configuration for a Delivery Controller.
Get-BrokerDesktopSessionReturns a list of active sessions for a desktop.
Get-BrokerSessionPolicyReturns a list of session policy settings.
Set-BrokerSessionPolicyModifies session policy settings.
Get-BrokerTagRestrictionReturns a list of tag restrictions.
Set-BrokerTagRestrictionModifies tag restrictions.
Get-BrokerUserReturns information about a user.
Get-BrokerUserSessionReturns a list of active sessions for a user.
Get-BrokerUserTagReturns a list of tags assigned to a user.
Set-BrokerUserTagModifies the tags assigned to a user.
Add-BrokerMachineCatalogTagRestrictionAdds a tag restriction to a machine catalog.
Remove-BrokerMachineCatalogTagRestrictionRemoves a tag restriction from a machine catalog.
Add-BrokerDesktopGroupUserAdds a user to a desktop group.
Remove-BrokerDesktopGroupUserRemoves a user from a desktop group.
Get-BrokerDesktopGroupMemberReturns a list of members of a desktop group.
Get-BrokerLogonDataReturns logon data for a user.
Get-BrokerSiteAggregationStateReturns the aggregation state of the site.
Start-BrokerRebalanceStarts the rebalance process for a machine catalog.
Stop-BrokerRebalanceStops the rebalance process for a machine catalog.
Citrix StoreFront commands
Add-STFAppGroupMemberAdds a published application to an application group.
Add-STFAppStoreAdds a Citrix StoreFront store to a Citrix Receiver client.
Get-STFAppStoreReturns a list of Citrix StoreFront stores.
Get-STFAppSubscriptionReturns a list of subscribed applications.
Remove-STFAppGroupMemberRemoves a published application from an application group.
Remove-STFAppStoreRemoves a Citrix StoreFront store from a Citrix Receiver client.
Set-STFAppStoreModifies the configuration for a Citrix StoreFront store.

Machine Catalog and Delivery group PowerShell Commands

CommandExplanation
Machine Catalog commands
New-BrokerMachineCatalogCreates a new machine catalog.
Set-BrokerMachineCatalogModifies the configuration of a machine catalog.
Remove-BrokerMachineCatalogRemoves a machine catalog.
Add-BrokerMachineAdds a machine to a machine catalog.
Remove-BrokerMachineRemoves a machine from a machine catalog.
Enable-BrokerMachineEnables a machine in a machine catalog.
Disable-BrokerMachineDisables a machine in a machine catalog.
Set-BrokerMachinePowerActionConfigures the power action settings for a machine catalog.
Get-BrokerMachineReturns information about a machine.
Set-BrokerMachineModifies the configuration of a machine.
Delivery Group commands
New-BrokerDesktopGroupCreates a new desktop group.
Set-BrokerDesktopGroupModifies the configuration of a desktop group.
Remove-BrokerDesktopGroupRemoves a desktop group.
Add-BrokerDesktopGroupMemberAdds a machine or user to a desktop group.
Remove-BrokerDesktopGroupMemberRemoves a machine or user from a desktop group.
Get-BrokerDesktopGroupReturns information about a desktop group.
Set-BrokerDesktopGroupPolicyModifies the policy settings for a desktop group.
Get-BrokerDesktopGroupPolicyReturns the policy settings for a desktop group.
Get-BrokerApplicationReturns information about a published application.
New-BrokerApplicationCreates a new published application.
Set-BrokerApplicationModifies the configuration of a published application.
Remove-BrokerApplicationRemoves a published application.
Get-BrokerApplicationInstanceReturns information about a published application instance.
New-BrokerApplicationInstanceCreates a new published application instance.
Set-BrokerApplicationInstanceModifies the configuration of a published application instance.
Remove-BrokerApplicationInstanceRemoves a published application instance.

To find all the commands starting with a particular string or word, just type part of the PS cmdlet that you are looking for and press CTRL and SPACEBAR. This will invoke the IntelliSense help from within PowerShell. Eg below

Get-Broker

This way you can also see all the filters available for a PowerShell cmdlet

Another way of seeing the filters is by the use of Show-Command

Show-Command -Name <powershell command>

Doing so will invoke a GUI windows listing all the filters that you could use.

Now, how do you find the list of all the published applications in a farm along with who has got access to them.

Get-BrokerApplication | Select-Object Name, AssociatedUserFullNames, PublishedName | Format-Table

Here are ALL the switches that you can use for applications if you want to further fine-tune your results.

Parameters
AdminFolderName
AdminFolderUid
AllAssociatedDesktopGroupUUIDs
AllAssociatedDesktopGroupUids
ApplicationName
ApplicationType
AssociatedApplicationGroupUUIDs
AssociatedApplicationGroupUids
AssociatedDesktopGroupPriorities
AssociatedDesktopGroupUUIDs
AssociatedDesktopGroupUids
AssociatedUserFullNames
AssociatedUserNames
AssociatedUserSIDs
AssociatedUserUPNs
BrowserName
ClientFolder
CommandLineArguments
CommandLineExecutable
ConfigurationSlotUids
CpuPriorityLevel
Description
Enabled
HomeZoneName
HomeZoneOnly
HomeZoneUid
IconFromClient
IconUid
IgnoreUserHomeZone
LocalLaunchDisabled
MachineConfigurationNames
MachineConfigurationUids
MaxPerMachineInstances
MaxPerUserInstances
MaxTotalInstances
MetadataKeys
MetadataMap
Name
PublishedName
SecureCmdLineArgumentsEnabled
ShortcutAddedToDesktop
ShortcutAddedToStartMenu
StartMenuFolder
Tags
UUID
Uid
UserFilterEnabled
Visible
WaitForPrinterCreation
WorkingDirectory

I will keep updating the list as we go.

Note that this is just a selection of commands and their explanations, and there are many more available. It’s always a good idea to refer to official Citrix documentation and best practices when using these commands in production environments.

2 responses to “Citrix Virtual Apps and Desktops – Commonly used PowerShell commands”

  1. […] If you want to know more on some of the powerful powershell cmdlets that you can use to to fine-tune your results, make sure you check the article here Citrix PowerShell Cheat Sheet […]

  2. […] I also have this article here discussing how to perform certain tasks in the Citrix farm such as get a list of the applications with user assignments. The link could be found here Commonly Used PowerShell Commands […]

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.