onsdag den 13. april 2011

Getting list of XenApp hotfixes, installing hotfix’es unattended from powershell

Searched high and low for this, and couldn’t find anything, so here is my version.

# Regiser Addins if missing
$snapin = Get-PSSnapin | where {$_.name -eq 'Citrix.Common.Commands'}
if($snapin -eq $null){ Add-PSSnapin Citrix.Common.Commands }
$snapin = Get-PSSnapin | where {$_.name -eq 'Citrix.XenApp.Commands'}
if($snapin -eq $null){ Add-PSSnapin Citrix.XenApp.Commands }

function installXenappHotfix([string]$HotfixName, [string]$hotfixpath ){
# Get current computername and XenServer object
$computername = get-content env:computername

$isInstalled = $false;
foreach($hotfix in (Get-XAServerHotFix -ServerName $computername)){
if($hotfix.HotfixName -eq $HotfixName){ $isInstalled = $true; }
}
if($isInstalled -eq $false){
Write
-Host ('Missing ' + $HotfixName)
$exitcode = (Start-Process -FilePath "msiexec.exe" -ArgumentList "/qb /passive /norestart /p `"$hotfixpath`"" -Wait -Passthru).ExitCode
if($exitcode -eq 3010){
$exitcode = 1604
Write
-Host 'Restart needed, so restarting. doh!'
restart
-computer -force -throttlelimit 10; exit $exitcode
exit
$exitcode
}
if($exitcode -ne 0){
Write
-Host ('Unknown exitcode: ' + $exitcode)
exit
$exitcode
}
}
else { Write-Host ($HotfixName + ' ok') }
}

installXenappHotfix 'XA600W2K8R2X64001' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64001.msp'
installXenappHotfix 'XA600W2K8R2X64002' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64002.msp'
installXenappHotfix 'XA600W2K8R2X64003' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64003.msp'
installXenappHotfix 'XA600W2K8R2X64004' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64004.msp'
installXenappHotfix 'XA600W2K8R2X64006' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64006.msp'
installXenappHotfix 'XA600W2K8R2X64007' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64007.msp'
installXenappHotfix 'XA600W2K8R2X64008' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64008.msp'
installXenappHotfix 'XA600W2K8R2X64009' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64009.msp'
installXenappHotfix 'XA600W2K8R2X64010' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64010.msp'
installXenappHotfix 'XA600W2K8R2X64011' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64011.msp'
installXenappHotfix 'XA600W2K8R2X64012' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64012.msp'
installXenappHotfix 'XA600W2K8R2X64013' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64013.msp'
installXenappHotfix 'XA600W2K8R2X64015' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64015.msp'
installXenappHotfix 'XA600W2K8R2X64016' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64016.msp'
installXenappHotfix 'XA600W2K8R2X64017' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64017.msp'
installXenappHotfix 'XA600W2K8R2X64018' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64018.msp'
installXenappHotfix 'XA600W2K8R2X64019' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64019.msp'
installXenappHotfix 'XA600W2K8R2X64020' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64020.msp'
installXenappHotfix 'XA600W2K8R2X64021' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64021.msp'
installXenappHotfix 'XA600W2K8R2X64023' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64023.msp'
installXenappHotfix 'XA600W2K8R2X64026' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64026.msp'
installXenappHotfix 'XA600W2K8R2X64027' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64027.msp'
installXenappHotfix 'XA600W2K8R2X64028' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64028.msp'
installXenappHotfix 'XA600W2K8R2X64029' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64029.msp'
installXenappHotfix 'XA600W2K8R2X64030' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64030.msp'
installXenappHotfix 'XA600W2K8R2X64031' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64031.msp'
installXenappHotfix 'XA600W2K8R2X64033' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64033.msp'
installXenappHotfix 'XA600W2K8R2X64035' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64035.msp'
installXenappHotfix 'XA600W2K8R2X64036' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64036.msp'
installXenappHotfix 'XA600W2K8R2X64037' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64037.msp'
installXenappHotfix 'XA600W2K8R2X64038' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64038.msp'
installXenappHotfix 'XA600W2K8R2X64039' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64039.msp'
installXenappHotfix 'XA600W2K8R2X64041' 'X:\XenApp
6 hotfixes\XA600W2K8R2X64041.msp'

Ingen kommentarer:

Send en kommentar