Skip to content
Menu
Tech Automation Blog
  • About Author
  • Contact
Tech Automation Blog

Complete XenApp 6.x Farm Inventory using Powershell

Posted on August 31, 2019February 27, 2022

Today, I am going to share a script to create an inventory of XenApp 6.x farm servers and applications. Like my VMware inventory script provided in my earlier blog, I use output csv of this script execution and ingest data into my SQL Database. After that, generate different reports by querying other tables in the Database to produce nice data set which helped my Organization with different reports.

This script requires XenApp Powershell Snap-in to be installed. It should be taken care by the script itself. Make sure you run Powershell with elevated permission. In addition, run this script from the Zone Data Collector. However, you can also run it on a management XenApp Server.

Thanks for the download and let me know if you face any issue.

$erroractionpreference = "SilentlyContinue"
Add-PSSnapin Citrix*
$currentDir = $(Get-Location).Path
$oFarmName = (Get-XAFarm | Select-Object FarmName).FarmName
$osrvPath = "$($currentDir)\$($oFarmName)_SERVER.csv"			
if(Test-Path $osrvPath){Remove-Item $osrvPath -Force}
ForEach($srv1 in Get-XAServer)
{
	$srvName = $srv1.ServerName
	$srvFolder = $srv1.FolderPath -Replace("/","\")
	$srvZone = $srv1.ZoneName
	$srvElect = $srv1.ElectionPreference
	$srvIP = $srv1.IPAddresses -Join ";"
	$srvCtxPrd = $srv1.CitrixProductName
	$srvCtxVer = $srv1.CitrixVersion
	$srvCtxEdn = $srv1.CitrixEdition
	$srvCtxSP = $srv1.CitrixServicePack
	$srvInsDate = $srv1.CitrixInstallDate.ToString("dd-MMM-yyyy")
	$srvLicSrv = $srv1.LicenseServerName
	$srvLicPort = $srv1.LicenseServerPortNumber
	$srvLogonStat = $srv1.LogOnsEnabled
	$srvLogonMode = $srv1.LogOnMode
	$tmpPubApp = Get-XAApplication -ServerName $srv1 | Select-Object DisplayName
	if(!([string]::IsNullOrEmpty($tmpPubApp))){
		$tmpapp = $publisedApp = ""
		ForEach($p in $tmpPubApp){
			$tmpapp = $p.DisplayName				
			"$oFarmName,$srvName,$srvFolder,$srvZone,$srvElect,$srvIP,$srvCtxPrd,$srvCtxVer,$srvCtxEdn,$srvCtxSP,$srvInsDate,$srvLogonStat,$srvLogonMode,$tmpapp" | Out-File $osrvPath -Append -Encoding ASCII 													
		}
	}
	else{
		$tmpapp = ""
		"$oFarmName,$srvName,$srvFolder,$srvZone,$srvElect,$srvIP,$srvCtxPrd,$srvCtxVer,$srvCtxEdn,$srvCtxSP,$srvInsDate,$srvLogonStat,$srvLogonMode,$tmpapp" | Out-File $osrvPath -Append -Encoding ASCII 													
	}
}

$oappPath ="$($currentDir)\$($oFarmName)_APPLICATION.csv"	
if(Test-Path $oappPath){Remove-Item $oappPath -Force}
Get-XAApplication | foreach-object{ 
	Get-XAApplicationReport $_.BrowserName | ForEach-Object{
		$appInfo = $_	
		if($appInfo.InstanceLimit -eq -1){$appInstanceLimit = "No Limit"}else{$appInstanceLimit = $appInfo.InstanceLimit}
		$appName = $AppInfo.DisplayName
		$appFolderPath = $AppInfo.FolderPath -Replace("/","\")
		$appType = $AppInfo.ApplicationType
		$appStatus = $AppInfo.Enabled
		$appUserAccess = $AppInfo.Accounts -join ";"
		$appXAServers = $AppInfo.ServerNames -join ";"
		$appXAWGroups = $AppInfo.WorkerGroupNames -join ";"
		$appCmdLine = $AppInfo.CommandLineExecutable
		$appWorkingDirectory = $AppInfo.WorkingDirectory
		$appClientFolder = $AppInfo.ClientFolder
		$appAddToClientDesktop = $AppInfo.AddToClientDesktop
		$appEncLevel = $AppInfo.EncryptionLevel
		$appWindowType = $AppInfo.WindowType
		$appColor = $AppInfo.ColorDepth
		$appMulInstPerUser = $AppInfo.MultipleInstancesPerUserAllowed
		$appWaitOnPrn = $AppInfo.WaitOnPrinterCreation
		$appAudioRequired = $AppInfo.AudioRequired
		"$oFarmName,$appName,$appFolderPath,$appType,$appStatus,$appUserAccess,$appXAServers,$appXAWGroups,$appCmdLine,$appWorkingDirectory,$appEncLevel,$appWindowType,$appColor,$appInstanceLimit,$appMulInstPerUser,$appWaitOnPrn,$appAudioRequired" | Out-File $oappPath -Append -Encoding ASCII	
	}
}	
execute powershell script

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
May 2025
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« May    

Recent Posts

  • Monitor and alert Azure Service Health issues May 5, 2020
  • AWS IAM User access review May 3, 2020
  • Integrate Azure Security Center with Event Hub April 28, 2020
  • Add Tags to Azure Subscription April 24, 2020
  • Automate Azure billing report in Excel March 6, 2020

Categories

©2025 Tech Automation Blog | Powered by SuperbThemes