Sunday, June 26, 2011

PowerShell: Retrieving Citrix server names that are having a paricular software installed

I want to list the Citrix server names on which Acrobat Reader X installed. Following PowerShell script is helpful for that. This script will store the server list in a log file as well as display the server list in the console.

cls
Add-PSSnapin Citrix.XenApp.Commands


##########################################
# Declaring a log file to store the result
##########################################

$log_file = 'C:\InstalledServers.txt'
Clear-Content $log_file


#########################
# Getting list of Citrix servers
#########################
$servers = Get-XAServer

#######################
# Storing result in the log fle
#######################

ECHO "List of Servers having Adobe Reader X installed" >> $log_file
ECHO "************************************************" >> $log_file



Write-Host "List of Servers having Adobe Reader X installed"
foreach($server in $servers)
{
 $colItems = get-wmiobject -class "Win32_Product" -namespace "root\CIMV2" -ComputerName $server | where-object { $_.Caption -eq 'Adobe Reader X' }
 

$colItems.__SERVER >> $log_file
 write-host $colItems.__SERVER
}

No comments:

Post a Comment