Vérifier les Hotfix de Citrix (Pas encore testé)

Voici un petit script qui permet de faire un comparatif des hotfix pour une liste de serveur… de manière manuel…



Source : http://bsonposh.com/archives/421

Code:
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


Param($file,$filter=".*",$server)

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

Merci Macgor, je me suis permis d’éditer ton message sur l’affichage du code.