This commit is contained in:
scriptos 2023-11-29 14:56:08 +01:00
parent 5d36f31544
commit 73731b23b4

View File

@ -1,4 +1,4 @@
# Script Name: windows-updater.ps1 # Script Name: windows-updater.ps1
# Beschreibung: Installiert Windows Updates # Beschreibung: Installiert Windows Updates
# Lauffähig unter Windows Server 2016, 2019 und 2022 # Lauffähig unter Windows Server 2016, 2019 und 2022
# Aufruf: - # Aufruf: -
@ -17,9 +17,15 @@ function Format-DeutschesDatum ([datetime] $date) {
# Variablen # Variablen
$LogPfad = "C:\logs\windows-updater.log" $LogPfad = "C:\logs\windows-updater.log"
$ModulVerzeichnis = Join-Path -Path $PSScriptRoot -ChildPath "Module" $ModulVerzeichnis = Join-Path -Path $PSScriptRoot -ChildPath "Modules"
$env:PSModulePath += ";$ModulVerzeichnis" $env:PSModulePath += ";$ModulVerzeichnis"
# Zeitstempel für das Logfile
$LogZeitstempel = Format-DeutschesDatum (Get-Date)
$LogEintrag = "Script gestartet am: $LogZeitstempel"
Write-Host $LogEintrag
$LogEintrag | Out-File -Append -FilePath $LogPfad
# Importiere das PSWindowsUpdate-Modul # Importiere das PSWindowsUpdate-Modul
Import-Module -Name "PSWindowsUpdate" -Verbose Import-Module -Name "PSWindowsUpdate" -Verbose
@ -46,3 +52,9 @@ if (Get-Module -Name PSWindowsUpdate -ListAvailable) {
} else { } else {
Write-Host "Fehler beim Laden des PSWindowsUpdate-Moduls." Write-Host "Fehler beim Laden des PSWindowsUpdate-Moduls."
} }
# Zeitstempel für das Logfile nach Abschluss des Skripts
$LogZeitstempel = Format-DeutschesDatum (Get-Date)
$LogEintrag = "Script beendet am: $LogZeitstempel"
Write-Host $LogEintrag
$LogEintrag | Out-File -Append -FilePath $LogPfad