/citrix-odata

PowerShell Module to collect Citrix Virtual Apps and Desktops usage data from the Citrix Monitor Service OData API

Primary LanguagePowerShellMIT LicenseMIT

citrix-odata

citrix-odata is a PowerShell Module that uses the Citrix Monitor Service OData API to collect usage data from a Citrix Virtual Apps and Desktops installation. You can then use the collected data to feed your own monitoring dashboards or other similar projects.

Features

citrix-odata can query Citrix Virtual Apps and Desktops sites versions 7.6 and later to return the following usage data about the installation:

  • Maximum concurrent sessions per Delivery Group
  • Average login time per Delivery Group
  • Connection failures per Delivery Group
  • Machine count per Delivery Group

The information is returned to a PSCustomObject that can then be transformed to JSON, XML or plain text using the standard PowerShell cmdlets.

Getting started

Currently, the module has been tested on Windows PowerShell 5.0 and later versions, but an effort to test and support PowerShell Core is ongoing. To use this module you can:

  • Use PowerShellGet to download and install the module from PowerShell Gallery:
Install-Module -Name citrix-odata
  • Or, alternatively, download the code from the project site and run the following commands from the uncompressed file directory:
cd Source
Import-Module .\citrix-odata.psd1

PowerShellGet is bundled by default with Windows 10, Windows Server 2016, WMF 5 and PowerShell 6 and is the preferred installation method.

Usage

After installing the module, you can run the Get-CitrixMonitorServiceData cmdlet to retrieve the usage data. You can store the retrieved data to a variable and then transform the results object to JSON or other format as you need.

citrix-odata demo

Arguments

-DeliveryControllers

This parameter is mandatory. Specifies a single Citrix Virtual Apps and Desktops Delivery Controller or an array of Citrix DDCs from different Sites to collect data from.

-Credential

Specifies a user account that has permission to send the request. The default is the current user. A minimum of read-only administrator permissions on Citrix Virtual Apps and Desktops are required to collect this data.

Enter a PSCredential object, such as one generated by the Get-Credential cmdlet.

-StartDate

Specifies the start date for the report in yyyy-MM-ddTHH:mm:ss format. If you omit the time part, 00:00:00 will be automatically appended to the date.

The default value is yesterday's date, midnight.

-EndDate

Specifies the end date for the report in yyyy-MM-ddTHH:mm:ss format. If you omit the time part, 23:59:59 will be automatically appended to the date.

The default value if no start date is specified is yesterday's date, 23:59:59. If a start date is specified but no end date is provided, the end date will automatically be set 23 hours, 59 minutes and 59 seconds after the start date.

Usage examples

Example 1

Returns the usage data for all Delivery Groups present on myddc01 and myddc02 Delivery Controllers using the specified credentials. The returned custom object will contain yesterday's usage data. The data is then transformed to JSON and stored in the $Result variable.

$Result = Get-CitrixMonitorServiceData -DeliveryControllers @('myddc01.example.com', 'myddc02.example.com') -Credential $(Get-Credential) | ConvertTo-Json -Depth 5

Example 2

Returns the usage data for all Delivery Groups present on myddc01 using the credentials of the current user. The returned custom object will contain the usage data for the month of August 2019.

Get-CitrixMonitorServiceData -DeliveryControllers 'myddc01.example.com' -StartDate '2019-08-01T00:00:00' -EndDate '2019-08-31T23:59:59'