diff --git a/windows-updater.ps1 b/windows-updater.ps1 index 84f1187..d951757 100644 --- a/windows-updater.ps1 +++ b/windows-updater.ps1 @@ -5,20 +5,25 @@ # Autor: Patrick Asmus # Web: https://www.media-techport.de # Git-Reposit.: https://git.media-techport.de/scriptos/windows-updater.git -# Version: 1.0 -# Datum: 29.11.2023 -# Modifikation: Erste Veröffentlichung +# Version: 1.1 +# Datum: 30.11.2023 +# Modifikation: log-dir wird erstellt wenn nicht vorhanden ##################################################### +# Variablen +$LogPfad = "C:\logs\windows-updater.log" +$ModulVerzeichnis = Join-Path -Path $PSScriptRoot -ChildPath "Modules" +$env:PSModulePath += ";$ModulVerzeichnis" + # Funktion zur Formatierung des Datums im deutschen Stil function Format-DeutschesDatum ([datetime] $date) { return $date.ToString("dd.MM.yyyy HH:mm:ss") } -# Variablen -$LogPfad = "C:\logs\windows-updater.log" -$ModulVerzeichnis = Join-Path -Path $PSScriptRoot -ChildPath "Modules" -$env:PSModulePath += ";$ModulVerzeichnis" +# Überprüfe, ob der Log-Ordner existiert, andernfalls erstelle ihn +if (-not (Test-Path -Path $LogPfad)) { + New-Item -ItemType Directory -Path (Split-Path $LogPfad) -Force +} # Zeitstempel für das Logfile $LogZeitstempel = Format-DeutschesDatum (Get-Date)