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*
or
asnp citrix*
To get Citrix Director versions
Get-BrokerController
To get DB location
Get-LogDatastore
To get Monitor DB location
Get-MonitorDatastore
To get Broker DB location
Get-BrokerDbconnection
To Get Broker DB version
Get-BrokerInstalledDbVersion
Test connections
Test-BrokerDBconnection connection strings
Test-ConfigDBConnection connection strings
To get PVS version
Get-PvsServer
To get PVS server Name
Get-PvsServerName
To get PVS server Status
Get-PvsServerStatus
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
New-BrokerRebootScheduleV2
Lists existing reboot schedules
Get-BrokerRebootScheduleV2
Update an existing reboot schedule
Set-BrokerRebootScheduleV2
Remove a reboot schedule
Remove-BrokerRebootScheduleV2
Rename a reboot schedule
Rename-BrokerRebootScheduleV2