Test-CitrixHotfix
I often find the need to compare the state of my PS servers. This little script allows me to find all the Citrix hotfixes for a group of server(s), or list of server(s) that have a specific hotfix.
Parameters:
$File: The name of the file which contains a list of servers
$Filter: Name or Regex of the Hotfix(es) to return
$Server: Name of the server to check
What it returns (a custom object):
ServerName: Name of the Server with the Hotfix(es)
Hotfixes: List of hotfix names [String[]]
RawObjects: Array of MFCOM MetaFrameHotfix objects
Examples
To List all the Hotfixes on a list of servers
.\Test-CitrixHotfix.ps1 ServerList.txt
To List a Specific hotfix on a list of servers
.\Test-CitrixHotfix.ps1 ServerList.txt -filter PSE450W2K3021
To List all the hotfixes on a specific Server
.\Test-CitrixHotfix.ps1 -s Server1
To List a specific hotfix for a specific server
.\Test-CitrixHotfix.ps1 -s Server1 -filter PSE450W2K3021
The Code:
Function Ping-Server {
Param([string]$server)
$pingresult = Get-WmiObject win32_pingstatus -f "address=’$Server’"
if($pingresult.statuscode -eq 0) {$true} else {$false}
}
Function Check-CitrixHotfix{
Param([string]$server)
$mf = New-Object -ComObject MetaframeCOM.MetaframeFarm
$mf.Initialize(1)
$srv = $mf.GetServer2(6,$server)
$list = $srv.winServerObject2.hotfixes | ?{$_.Name -match $filter}
$list
}
if($file -and (Test-Path $file))
{
$servers = cat $file
}
if($input)
{
$servers = $input
}
if($server){$servers += $server}
foreach($srv in $servers)
{
if(Ping-Server $srv)
{
$hotfixes = Check-CitrixHotfix $srv
$myobj = "" | Select-Object ServerName,Hotfixes,RawObjects
$myobj.ServerName = $srv
$myobj.Hotfixes = $hotfixes | %{$_.Name}
$myobj.RawObjects = $hotfixes
$myobj
}
else
{
write-host $srv
write-host "————"
write-host "Server not pingable"
}
}
Leave a Reply
You must be logged in to post a comment.

