Citrix Powershell Potpourri

Purpose: The purpose of this article is to display a set of commonly used Citrix Powershell Scripts

To load all Citrix Snapins
Get-Command -PSSnapin Citrix*
asnp citrix*
To get Citrix Director versions
To get DB location
To get Monitor DB location
To get Broker DB location
To Get Broker DB version
Test connections
Test-BrokerDBconnection connection strings
Test-ConfigDBConnection connection strings
To get PVS version
To get PVS server Name
To get PVS server Status
To set Citrix License to base
Set-ConfigSite -ProductCode XDT -ProductEdition ADV -LicensingModel UserDevice

Parameters for New-BrokerRebootScheduleV2:

  • Name (A friendly name for the new reboot schedule)
  • DesktopGroupName (The name of the Delivery Group to which the reboot schedule is being applied)
  • RebootDuration (Approximate maximum number of minutes over which the scheduled reboot cycle runs)
  • Day (For weekly cycles, the day of the week on which the scheduled reboot cycle starts)
  • Description (An optional description for the reboot schedule)
  • Enabled (Boolean that indicates if the new reboot schedule is enabled)
  • Frequency (Frequency with which this schedule runs – either weekly or daily)
  • RestrictToTag (If set, the reboot schedule only applies to machines in the Delivery Group with the specified tag)
  • StartTime (Time of day at which the scheduled reboot cycle starts)
  • WarningDuration (Time prior to the start of a machine reboot at which a warning message is displayed to all the users on the machine)
  • WarningMessage (Warning message displayed in user sessions on a machine scheduled for reboot)
  • WarningRepeatInterval (Time to wait after the previous reboot warning before displaying the warning message in all user sessions on that machine again)
  • WarningTitle (The window title used when showing the warning message in user sessions on a machine scheduled for reboot)

Here is an example of a command:

New-BrokerRebootScheduleV2 -Name ‘Saturday Reboots for 2012 R2’ -DesktopGroupName ‘Windows Server 2012 R2 Delivery Group’ -Day Saturday -Frequency Weekly -StartTime “2:00” -RebootDuration 120 -RestrictToTag Saturday -WarningDuration 30 -WarningRepeatInterval 10 -WarningMessage “This machine will restart in %m% minutes. Please save your work.” -WarningTitle “Warning: Reboot Pending” -Enabled $true

This command will reboot all machines tagged ‘Saturday’ in the Windows Server 2012 R2 Delivery Group every Saturday between 2-4 am. Thirty minutes prior to the reboot, users will be warned about the pending reboot with a message titled “Warning: Reboot Pending” and stating, “This machine will restart in %m% minutes. Please save your work.”, where %m% will be replaced with the number of minutes remaining until the reboot. This warning will be repeated every 10 minutes until the machines are restarted.

Creates a new reboot schedule for a Delivery Group
Lists existing reboot schedules
Update an existing reboot schedule
Remove a reboot schedule
Rename a reboot schedule