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
}
}