PowerShell script to get applications subscribed by a user or published to a user in Citrix Xenapp 7.7
Earlier we saw that how to publish applications in Citrix XenApp 7.7 using PowerShell and add the required user to the published application's AssociatedUsers Property/Array. Refer the following link for the same:
After the applications are published and the users who want to use particular applications are added, there may be a need to get the list of Applications that the user has subscribed to/applications published to the user. This is the purpose of this post. The following script accepts UserId as the input parameter and then iterates through each of the published applications to find out all those applications which have the user's name in their AssociatedUsers Property. All the App names which satisfy this criteria are collected in an array and then printed. I have also tried my best add as many as possible comments so that the script is easy to understand. Also I have given a link at the end of the page from which you can download the below script.
You can download the script from the below link:
#------------------------------------------------------------------------------------------- # Purpose : This Script gives the list of applications that a user(say sam.ray@mycompany.com) has subscribed to. # Author : Sam Ray # Email : prac.codes@gmail.com # Input Parameters : UserId #------------------------------------------------------------------------------------------- #-------------------------------------SCRIPT STARTS HERE-------------------------------------# # Getting the first parameter passed (This parameter is the userid e.g sam.ray@mycompany.com) $userid=$args[0] # Making an empty application array which will contain all the apps that are subscribed by the user $AppArray = @() # Adding Citrix PoweShell SnapIns If ( (Get-PSSnapin -Name Citrix* -ErrorAction SilentlyContinue) -eq $null ) { Add-PSSnapin Citrix* } # The following code gets the apps that user has subscribed and adds them to the $AppArray. # Logic : 1) Get all the published applications. # 2) Check for the obtained userid's entry in every application's AssociatedUserUPNs property/array. # 3) If present - add that application to $AppArray, else go to the next application and repeat... foreach($application In Get-BrokerApplication) { #Write-Host $application.ApplicationName foreach($user In $application.AssociatedUserUPNs) { #Write-Host $user if($user -eq $userid) { #Add this application to the array of applications for the user $AppArray += $application.ApplicationName } } } # Print the $AppArray to show the list of users that the user has subscribed to. (e.g. VLC, Notepad++, etc...) foreach($app In $AppArray) { Write-Host $($app + "," ) } #-------------------------------------SCRIPT ENDS HERE-------------------------------------#
You can download the script from the below link (Hosted on Google Drive):
Get User Subscribed Apps PoweShell Script
Thanks!!
Get User Subscribed Apps PoweShell Script
Thanks!!
No comments:
Post a Comment
Thanks for your valuable comment