PowerShell: Obtain user information from Citrix Director
When using a Citrix Environment there might be times when you need to find the end users computer information, what deliver group they are in and much more on the fly. Going to Citrix Director can be slow and time consuming. Below is a PowerShell script I wrote to help pull this information using the Citrix PowerShell module from the remote controller server. The following code will query and output the following information found on the logged in user.
UserUPN
SessionState
CatalogName
ClientAddress
ClientName
HostedMachineName
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Force TLS 1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Citrix Controller Server $Controller = "CitrixControllerServer" # Import Remote Modules from Controllers # Create a Powershell Remote session to the selected Desktop Controller with the XenDesktop snap-ins installed. write-host "[~] Connecting to" $Controller -foreground "magenta" $RemoteSession = New-PSsession -Computername $Controller # Use the newly created Remote Powershell session to send a #command to that session write-host "[~] Importing addon snapins for Citrix" -foreground "cyan" Invoke-Command -Command {add-pssnapin Citrix.*} -Session $RemoteSession # new command name prefix. write-host "[~] Importing session" -foreground "green" Import-PSSession -Session $RemoteSession -Module Citrix.* write-host "[~] Search Citrix for User info" -foreground "Cyan" $User = Read-Host -Prompt "Enter Username" $UserInfo = Get-BrokerSession | select UserUPN, SessionState, CatalogName, ClientAddress, ClientName, HostedMachineName | Sort-Object CatalogName | Where-Object UserUPN -like $User* $UserInfo Remove-PSSession -ID $RemoteSession.ID |