User Tools

Site Tools


userspace:windows_updates

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
userspace:windows_updates [2013/01/09 18:00]
tobias [Updates on the Fly]
userspace:windows_updates [2021/08/23 08:37] (current)
Line 211: Line 211:
  
 ====== Windows Updates (Alternative) ====== ====== Windows Updates (Alternative) ======
 +This Script is maintained by:  --- //[[tobias.friede@wki.fraunhofer.de|tobias]] 2013/03/01 18:06//
  
 +This is an alternative way to install all Windows & Office Updates on the fly after Windows installation.
 +The script is based on WUInstall Pro ([[http://wuinstall.com/]]) - but i think it will work with the free version too (maybe with small changes)
 +It's Important that you have a WSUS Server in your Network because the checkroutine uses an WSUS to check for outstanding updates. 
 +
 +**Update: The option /use_wsus is only available in WuInstallPRO!**
 +
 +The option /use_wsus is only needed by users who do not have a ActiveDirectory with an active WSUS Group policy. If you do not have an ActiveDirectory you can set the option via registry.
 +
 +----
 Ich habe eine weitere Variante entwickelt um Updates automatisiert nach der OS Installation auf den Client zu bringen. Ich habe eine weitere Variante entwickelt um Updates automatisiert nach der OS Installation auf den Client zu bringen.
-Mein Script basiert auf dem Programm [[http://wuinstall.com/ WUInstall]] getestet und entwickelt habe ich das Script mit der Pro Version - ich denke es wird auch mit der Free Version funktionieren.+Mein Script basiert auf dem Programm WUInstall ([[http://wuinstall.com/]]getestet und entwickelt habe ich das Script mit der Pro Version - ich denke es wird auch mit der Free Version funktionieren.
  
 Das Script startet WUInstall welches ALLE Updates vom WSUS installiert alternativ auch aus dem Internet. Das Script startet WUInstall welches ALLE Updates vom WSUS installiert alternativ auch aus dem Internet.
Line 220: Line 230:
 Das Script ist getestet auf Windows 7 x64 und x86 sollte aber auch auf Windows XP funktionieren wenn dort die Powershell installiert ist!  Das Script ist getestet auf Windows 7 x64 und x86 sollte aber auch auf Windows XP funktionieren wenn dort die Powershell installiert ist! 
  
 +=== Folgendes muss beachtet werden: ===
 +- Wenn Optionale Updates angeboten werden, werden diese nicht automatisch installiert und das Powershellscript wird nie 0 zurückgeben!
  
-<code winst>+- Das Script hat eine Geringe Priorität, daher wird es nahezu als letztes ausgeführt. Das ist wichtig damit alle Produkte die darüber mit Updates versorgt werden, diese auch enthalten. 
  
 +==== Setup.ins ====
 +<code winst>
 [ACTIONS] [ACTIONS]
-DefVar $Flag$+ 
 +; -------- Define Variables -------------------------
 DefVar $WinstRegKey$ DefVar $WinstRegKey$
 DefVar $RebootRegVar$ DefVar $RebootRegVar$
Line 231: Line 246:
 DefVar $trim$ DefVar $trim$
 DefVar $INST_SystemType$  DefVar $INST_SystemType$ 
 +Defvar $outstanding$
 +DefVar $ProductId$
 +DefVar $RebootCounter$
 +DefVar $NumberOfNeededReboots$
  
 +Set $WinstRegKey$ = "HKLM\SOFTWARE\opsi.org\winst"
 +Set $ProductID$ = "Windows Updates"
 Set $INST_SystemType$ = GetSystemType Set $INST_SystemType$ = GetSystemType
 +Set $NumberOfNeededReboots$ = GetProductProperty("NumberOfNeededReboots", "15")
  
 +ShowBitmap "%ScriptPath%\WU.png" $ProductId$
  
  
-;-------------------------------------------------------------------------------- +; ------------- Create Reboot flag registry key ---------------------------------------------- 
-; First run + 
-;-------------------------------------------------------------------------------- +if  (GetRegistryStringValue32("["+$WinstRegKey$+"] "+"RebootFlag"= ""
-if ($INST_SystemType$ = "64 Bit System") + set $RebootCounter$ = "0"
- DOSBatch_install_updates_x64+
 else else
- DOSBatch_install_updates_x86+ Set $RebootCounter$ = GetRegistryStringValue32("["+$WinstRegKey$+"] "+"RebootFlag")
 endif endif
  
-;-------------------------------------------------------------------------------- +;-------------------------- Patch Routine ----------------------------------------------------
-; Check & Reboot +
-;-------------------------------------------------------------------------------- +
-winbatch_psactivate +
-set $counterString$ = getOutStreamFromSection('execWith_powershell "Powershell"'+
-  +
-set $CounterVar$ = takeString(0,$CounterString$) +
-set $trim$ = trim($CounterVar$) +
-  +
-  +
-if $trim$ =  "0" +
- comment "Keine Updates Verfügbar" +
- ExitWindows /Reboot +
-  +
-else +
- ExitWindows /ImmediateReboot +
- comment weitere Updates verfügbar reboot wurde initialisiert !+
  
 +comment $RebootCounter$
 +comment $NumberOfNeededReboots$
 +if ($RebootCounter$ INT<= $NumberOfNeededReboots$)
 +
 + if ($INST_SystemType$ = "64 Bit System")
 + DOSBatch_install_updates_x64
 + else
 + DOSBatch_install_updates_x86
 + endif
 +
 +;---------------------------- Check pending updates ---------------------------------------
 + winbatch_psactivate
 + set $counterString$ = getOutStreamFromSection('execWith_powershell "Powershell"')
 + set $CounterVar$ = takeString(0,$CounterString$)
 + set $trim$ = trim($CounterVar$)
 + set $outstanding$ = $trim$ 
 + opsiServiceCall_report_pending_updates
 +  
 + if $trim$ =  "0"
 + comment "Keine Updates Verfuegbar"
 + set $RebootCounter$ = calculate($NumberOfNeededReboots$+"+1"
 + Registry_SaveRebootCounter
 + ExitWindows /Reboot
 + else
 +        set $RebootCounter$ = calculate($RebootCounter$+"+1")
 + opsiServiceCall_report_reboot
 + Registry_SaveRebootCounter
 + ExitWindows /ImmediateReboot
 + comment "weitere Updates verfuegbar reboot wurde initialisiert und Zaehler um 1 erhoeht"
 + endif
 +
 +else
 + set $RebootCounter$ = "0"
 + Registry_SaveRebootCounter
 + Comment "Maximale Anzahl durchlaeufe erreicht, RebootCounter (Rebootflag) zurueckgesetzt auf 0"
 endif endif
 +
  
  
  
 +; ----------- Sections -------------------------------------------------------------------------------------
  
 [DOSBatch_install_updates_x64] [DOSBatch_install_updates_x64]
-%scriptpath%/WUInstallX64.exe /install /use_wsus http://153.96.112.15 /logfile_append c:/tmp/wuinstall.log  +%scriptpath%/WUInstallX64.exe /install /use_wsus http://xxxx.15 /logfile_append c:/tmp/wuinstall.log 
  
 [DOSBatch_install_updates_x86] [DOSBatch_install_updates_x86]
-%scriptpath%/WUInstallX86.exe /install /use_wsus http://153.96.112.15 /logfile_append c:/tmp/wuinstall.log +%scriptpath%/WUInstallX86.exe /install /use_wsus http://xxxx.15 /logfile_append c:/tmp/wuinstall.log 
  
 [winbatch_psactivate] [winbatch_psactivate]
 powershell Set-ExecutionPolicy RemoteSigned powershell Set-ExecutionPolicy RemoteSigned
- 
- 
  
 [execWith_powershell] [execWith_powershell]
Line 286: Line 326:
 write-host $list.updates.count write-host $list.updates.count
  
 +[Registry_SaveRebootCounter]
 +openKey [$WinstRegKey$]
 +set "RebootFlag" = "$RebootCounter$"
  
 +[opsiServiceCall_report_pending_updates]
 +"method": "setProductProperty"
 +"params": [
 +"windowsupdates",
 +"ausstehend",
 +"$outstanding$",
 +"%hostid%"
 +]
 +
 +[opsiServiceCall_report_reboot]
 +"method": "setProductProperty"
 +"params": [
 +"windowsupdates",
 +"rebootcounter",
 +"$RebootCounter$",
 +"%hostid%"
 +]
 +</code>
 +===control===
 +<code winst>
 +[Package]
 +version: 1
 +depends: 
 +incremental: False
 +
 +[Product]
 +type: localboot
 +id: windowsupdates
 +name: Windows Updates
 +description: Installiert Windowsupdates
 +advice: 
 +version: 1.5
 +priority: -89
 +licenseRequired: False
 +productClasses: 
 +setupScript: setup.ins
 +uninstallScript: 
 +updateScript: 
 +alwaysScript: 
 +onceScript: 
 +customScript: 
 +userLoginScript: 
 +
 +[ProductProperty]
 +type: unicode
 +name: ausstehend
 +multivalue: False
 +editable: True
 +description: Noch ausstehende Updates (nicht editieren)
 +values: ["0"]
 +default: ["0"]
 +
 +[ProductProperty]
 +type: unicode
 +name: rebootcounter
 +multivalue: False
 +editable: True
 +description: Anzahl bisheriger Neustarts (nicht editieren)
 +values: ["0"]
 +default: ["0"]
 +
 +[ProductProperty]
 +type: unicode
 +name: numberofneededreboots
 +multivalue: False
 +editable: True
 +description: Startet Rechner bei bedarf auf mehrmals neu
 +values: ["0", "10", "11", "12", "13", "14", "15", "3", "4", "5", "6", "7", "8", "9"]
 +default: ["15"]
  
-[Registry_SaveRebootFlag] 
-openKey [$WinstRegKey$] 
-set "RebootFlag" = "$Flag$" 
  
 </code> </code>
 +
 +==== Neuerungen / News: ====
 + --- //[[tobias.friede@wki.fraunhofer.de|tobias]] 2013/08/15 21:00//
 +
 +- Report pending Updates to Configed (realised with Produtctproperty)
 +
 +- Reboot counter (reported to Configed)
 +
 +- Maximum Reboots (Property) (Prevents continuous loop) 
userspace/windows_updates.1357754427.txt.gz · Last modified: 2021/08/23 08:37 (external edit)