User Tools

Site Tools


userspace:windows_updates_-_powershell

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_-_powershell [2017/03/02 09:43]
trabs-ol
userspace:windows_updates_-_powershell [2021/08/23 08:37] (current)
Line 1: Line 1:
-Mit diesem Script werden so lange Updates intstalliert bis keine mehr vorliegen. Die Updates werden nur nach 19 Uhr und vor 7 Uhr installiert um den User nicht an der Anmeldung zu hindern. Aussnahme: Der Rechner wurde neu installiert, dann werden unabhängig von der Uhrzeit alle Updates installiert. Mit dem ONCE Script werden immer alle Updates installiert, unabhänig von der Tageszeit.+====== WSUS Updates Powershell ======
  
-Voraussetzungen: Powershell Version >= 4+Mit diesem Script werden so lange Updates intstalliert bis keine mehr vorliegen. Die Updates werden nur nach 19 Uhr und vor 7 Uhr installiert um den User nicht an der Anmeldung zu hindern. Aussnahme: Der Rechner wurde neu installiert, dann werden unabhängig von der Uhrzeit alle Updates installiert. Mit dem ONCE Script werden immer alle Updates installiert, unabhängig von der Tageszeit. 
 + 
 +Voraussetzungen: Powershell Version >= 4.0 
 + 
 +Getestet unter Windows 7 x64 SP1 
 + 
 +Logging des Scriptes erfolgt in C:\tmp\windows-update-opsi.log 
 + 
 +Ordnerstruktur: 
 + 
 +CLIENT_DATA 
 +  * install-updates.ps1 
 +  * install-updates-once.ps1 
 +  * once64.ins 
 +  * setup64.ins 
 +  * windows_update_icon.png (nur fürs gute Aussehen) 
 + 
 +OPSI 
 +  * control
  
 setup64.ins setup64.ins
Line 21: Line 39:
 DefVar $MinimumSpace$ DefVar $MinimumSpace$
 DefVar $ExitCode$ DefVar $ExitCode$
- 
-DefStringList $Version_List$ 
-DefVar $Version$ 
  
 Set $LogDir$ = "%SystemDrive%\tmp" Set $LogDir$ = "%SystemDrive%\tmp"
Line 45: Line 60:
  ShowBitmap "%ScriptPath%\windows_update_icon.png" "Windows Update"  ShowBitmap "%ScriptPath%\windows_update_icon.png" "Windows Update"
  
- Message "Prüfe, ob Powershell Version >= 4 ist..." +        Files_Install /Sysnative
- set $Version_List$ = getOutStreamFromSection ("DosInAnIcon_PSVersion_check"+
- set $Version$ = takeString(2, $Version_List$) +
-  +
- if ($Version$ < "4"+
- Message "Powershell Version veraltet. Produkt Powershell auf setup setzen..." +
- opsiServiceCall_Powershell_Setup +
- Message "Neustart..." +
- ExitWindows /ImmediateReboot +
- else +
- Message "Powershell Version ist >= 4..." +
- endif +
-  +
-    Files_Install /Sysnative+
  Message "Installiere Windows Updates. Dies kann mehrere Stunden dauern."  Message "Installiere Windows Updates. Dies kann mehrere Stunden dauern."
  DosInAnIcon_WindowsUpate  DosInAnIcon_WindowsUpate
Line 64: Line 66:
  
 endif endif
- 
-[DosInAnIcon_PSVersion_check] 
-powershell.exe $PSVersionTable.PSVersion.Major 
  
 [Files_Install] [Files_Install]
 CheckTargetPath = "%Systemdrive%\tmp" CheckTargetPath = "%Systemdrive%\tmp"
-copy -u "%ScriptPath%\install-updates.ps1" "%Systemdrive%\temp\"+copy -u "%ScriptPath%\install-updates.ps1" "%Systemdrive%\tmp\"
  
 [DosInAnIcon_WindowsUpate] [DosInAnIcon_WindowsUpate]
-"%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy ByPass -command "& { "%Systemdrive%\temp\install-updates.ps1"; exit $lastexitcode }" +"%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy ByPass -command "& { "%Systemdrive%\tmp\install-updates.ps1"; exit $lastexitcode }"
- +
-[opsiServiceCall_Powershell_Setup] +
-"method": "setProductActionRequestWithDependencies" +
-"params":+
-           "powershell", +
-           "%HostID%", +
-           "setup" +
-          ]+
  
 [Sub_check_exitcode] [Sub_check_exitcode]
Line 131: Line 122:
 DefVar $MinimumSpace$ DefVar $MinimumSpace$
 DefVar $ExitCode$ DefVar $ExitCode$
- 
-DefStringList $Version_List$ 
-DefVar $Version$ 
  
 Set $LogDir$ = "%SystemDrive%\tmp" Set $LogDir$ = "%SystemDrive%\tmp"
Line 155: Line 143:
  ShowBitmap "%ScriptPath%\windows_update_icon.png" "Windows Update"  ShowBitmap "%ScriptPath%\windows_update_icon.png" "Windows Update"
  
- Message "Prüfe, ob Powershell Version >= 4 ist..." +        Files_Install /Sysnative
- set $Version_List$ = getOutStreamFromSection ("DosInAnIcon_PSVersion_check"+
- set $Version$ = takeString(2, $Version_List$) +
-  +
- if ($Version$ < "4"+
- Message "Powershell Version veraltet. Produkt Powershell auf setup setzen..." +
- opsiServiceCall_Powershell_Setup +
- Message "Neustart..." +
- ExitWindows /ImmediateReboot +
- else +
- Message "Powershell Version ist >= 4..." +
- endif +
-  +
-    Files_Install /Sysnative+
  Message "Installiere Windows Updates. Dies kann mehrere Stunden dauern."  Message "Installiere Windows Updates. Dies kann mehrere Stunden dauern."
  DosInAnIcon_WindowsUpate  DosInAnIcon_WindowsUpate
Line 174: Line 149:
  
 endif endif
- 
-[DosInAnIcon_PSVersion_check] 
-powershell.exe $PSVersionTable.PSVersion.Major 
  
 [Files_Install] [Files_Install]
 CheckTargetPath = "%Systemdrive%\tmp" CheckTargetPath = "%Systemdrive%\tmp"
-copy -u "%ScriptPath%\install-updates-once.ps1" "%Systemdrive%\temp\"+copy -u "%ScriptPath%\install-updates-once.ps1" "%Systemdrive%\tmp\"
  
 [DosInAnIcon_WindowsUpate] [DosInAnIcon_WindowsUpate]
-"%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -command "& { "%Systemdrive%\temp\install-updates-once.ps1"; exit $lastexitcode }" +"%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -command "& { "%Systemdrive%\tmp\install-updates-once.ps1"; exit $lastexitcode }"
- +
-[opsiServiceCall_Powershell_Setup] +
-"method": "setProductActionRequestWithDependencies" +
-"params":+
-           "powershell", +
-           "%HostID%", +
-           "setup" +
-          ]+
  
 [Sub_check_exitcode] [Sub_check_exitcode]
Line 328: Line 292:
  
  
-$LogPath = 'C:\tmp\windows-update-opsi.log'+$LogPath = "$env:SystemDrive\tmp\windows-update-opsi.log"
 $FirstRun = Test-Path -Path $LogPath $FirstRun = Test-Path -Path $LogPath
  
Line 571: Line 535:
  
  
-$LogPath = 'C:\tmp\windows-update-opsi.log'+$LogPath = "$env:SystemDrive\tmp\windows-update-opsi.log"
 $FirstRun = Test-Path -Path $LogPath $FirstRun = Test-Path -Path $LogPath
  
Line 738: Line 702:
 </code> </code>
  
-<code> 
-</code> 
- 
-<code> 
-</code> 
userspace/windows_updates_-_powershell.1488447782.txt.gz · Last modified: 2021/08/23 08:37 (external edit)