Introduction

Citrix includes the powershell cmdlet when installing, to manage and perform Citrix administrative task via powershell. These are some powershell command can be used. By default, these cmdlet is loaded automatically when the insallation is finsied. If it doesn’t load properly, use this commands to load.

Load Module

Add-PSSnapin Citrix

Alternative:

asnp citrix

Citrix Cheat Sheet

Powershell Cheat sheet

Get-Service -DisplayName *citrix* # Display all the Citrix services installed on the Delivery Controller.

CDF Control # Tool can a Citrix Administrator use to collect information to investigate issues with session performance?

# Check Broker EntitlementPolicyRule
Get-BrokerEntitlementPolicyRule
Set-BrokerEntitlementPolicyRule <Delivery-Group-name> -SessionReconnection <value> -LeasingBehavior Allowed|Disallowed

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

Get-BrokerApplication #Returns a list of published applications.
Get-BrokerCatalog`	# Returns a list of catalogs containing desktops.
Get-BrokerDesktop	# Returns a list of desktops.
Get-BrokerMachine	# Returns a list of machines in the site.
Get-BrokerSite		# Returns the configuration for the site.
New-BrokerDesktopGroup	# Creates a new desktop group.
New-BrokerIcon		# Creates a new published application icon.

New-BrokerMachineCatalog	# Creates a new machine catalog.
Remove-BrokerApplication	# Removes a published application.
Remove-BrokerDesktop		# Removes a desktop.
Remove-BrokerMachine		# Removes a machine.

Set-BrokerAccessPolicyRule	# Modifies an access policy rule.
Set-BrokerCatalogPowerAction	# Configures power management settings for a catalog.
Set-BrokerDesktopGroup		# Modifies a desktop group.
Set-BrokerIcon			# Modifies a published application icon.
Set-BrokerMachine		# Modifies a machine.

# Citrix Studio commands	
Add-BrokerEntitlementPolicyRule	# Adds an entitlement policy rule.
Add-BrokerMachine		# Adds a machine to the site.
Add-BrokerTag			# Adds a tag to a machine or catalog.
Export-BrokerDesktopGroup	# Exports a desktop group configuration to a file.
Get-BrokerEntitlementPolicyRule	# Returns a list of entitlement policy rules.
Get-BrokerEntitlementPolicyRuleFilter	# Returns a list of entitlement policy rule filters.
Get-BrokerHostingPowerAction	# Returns a list of power management settings for machines.
Get-BrokerMachineConfiguration	#Returns the configuration for a machine.
Import-BrokerDesktopGroup	# Imports a desktop group configuration from a file.
Remove-BrokerEntitlementPolicyRule	# Removes an entitlement policy rule.
Remove-BrokerMachineTag		# Removes a tag from a machine or catalog.
Set-BrokerDesktop		# Modifies a desktop.
Set-BrokerEntitlementPolicyRule	# Modifies an entitlement policy rule.
Set-BrokerTag			# Modifies a tag.
Test-BrokerCatalog		# Tests the connection to a catalog.

# Delivery Controller commands	
Get-BrokerController		# Returns the configuration for a Delivery Controller.
Set-BrokerController		# Modifies the configuration for a Delivery Controller.
Get-BrokerDesktopSession 	# Returns a list of active sessions for a desktop.
Get-BrokerSessionPolicy		# Returns a list of session policy settings.
Set-BrokerSessionPolicy		# Modifies session policy settings.
Get-BrokerTagRestriction	# Returns a list of tag restrictions.
Set-BrokerTagRestriction	# Modifies tag restrictions.
Get-BrokerUser			# Returns information about a user.
Get-BrokerUserSession		# Returns a list of active sessions for a user.
Get-BrokerUserTag		# Returns a list of tags assigned to a user.
Set-BrokerUserTag		# Modifies the tags assigned to a user.
Add-BrokerMachineCatalogTagRestriction		# Adds a tag restriction to a machine catalog.
Remove-BrokerMachineCatalogTagRestriction	# Removes a tag restriction from a machine catalog.
Add-BrokerDesktopGroupUser	# Adds a user to a desktop group.
Remove-BrokerDesktopGroupUser	# Removes a user from a desktop group.
Get-BrokerDesktopGroupMember	# Returns a list of members of a desktop group.
Get-BrokerLogonData		# Returns logon data for a user.
Get-BrokerSiteAggregationState	# Returns the aggregation state of the site.
Start-BrokerRebalance		# Starts the rebalance process for a machine catalog.
Stop-BrokerRebalance		# Stops the rebalance process for a machine catalog.

# Citrix StoreFront commands	
Add-STFAppGroupMember		# Adds a published application to an application group.
Add-STFAppStore			# Adds a Citrix StoreFront store to a Citrix Receiver client.
Get-STFAppStore			# Returns a list of Citrix StoreFront stores.
Get-STFAppSubscription		# Returns a list of subscribed applications.
Remove-STFAppGroupMember	# Removes a published application from an application group.
Remove-STFAppStore		# Removes a Citrix StoreFront store from a Citrix Receiver client.

# Machine Catalog and Delivery group PowerShell Commands
Machine Catalog commands	
New-BrokerMachineCatalog	# Creates a new machine catalog.
Set-BrokerMachineCatalog	# Modifies the configuration of a machine catalog.
Remove-BrokerMachineCatalog	# Removes a machine catalog.
Add-BrokerMachine		# Adds a machine to a machine catalog.
Remove-BrokerMachine		# Removes a machine from a machine catalog.
Enable-BrokerMachine		# Enables a machine in a machine catalog.
Disable-BrokerMachine		# Disables a machine in a machine catalog.
Set-BrokerMachinePowerAction	# Configures the power action settings for a machine catalog.
Get-BrokerMachine		# Returns information about a machine.
Set-BrokerMachine		# Modifies the configuration of a machine.

# Delivery Group commands	
New-BrokerDesktopGroup		# Creates a new desktop group.
Set-BrokerDesktopGroup		# Modifies the configuration of a desktop group.
Remove-BrokerDesktopGroup	# Removes a desktop group.
Add-BrokerDesktopGroupMember	# Adds a machine or user to a desktop group.
Remove-BrokerDesktopGroupMember	# Removes a machine or user from a desktop group.
Get-BrokerDesktopGroup		# Returns information about a desktop group.
Set-BrokerDesktopGroupPolicy	# Modifies the policy settings for a desktop group.
Get-BrokerDesktopGroupPolicy	# Returns the policy settings for a desktop group.
Get-BrokerApplication		# Returns information about a published application.
New-BrokerApplication		# Creates a new published application.
Set-BrokerApplication		# Modifies the configuration of a published application.
Remove-BrokerApplication	# Removes a published application.
Get-BrokerApplicationInstance	# Returns information about a published application instance.
New-BrokerApplicationInstance	# Creates a new published application instance.
Set-BrokerApplicationInstance	# Modifies the configuration of a published application instance.
Remove-BrokerApplicationInstance	# Removes a published application instance.

# Remove machine group machine goup
Get-Brokermachine -cataloguid  | remove-brokermachine

# To check the service status of all the Citrix Services
Get-Command Get-*ServiceStatus | Get-Unique | Select Name

# Measure the number of service instances registered for Delivery Controller.
Get-ConfigRegisteredServiceInstance | Measure

# Check Datastore
Get-LogDatastore
Get-MonitorDatastore

# Check presence of database connection string for all Citrix Services, run the following command:
Get-Command Get-*DBConnection | Get-Unique | Select Name

# Verify the installed DB schema version for all the services. 
Get-Command Get-*InstalledDBVersion | Get-Unique | Select Name

# Check golden / master image of Machine Catalog
Get-ProvScheme -ProvisioningSchemeUid (Get-BrokerCatalog -Name "CatalogName").ProvisioningSchemeId | Select MasterImageVM