From 24882839f3285a2a70e86a80f0e77f3d0eeaeeec Mon Sep 17 00:00:00 2001 From: X9 Dev Date: Thu, 16 Apr 2026 14:20:14 +0200 Subject: [PATCH] scripts: auto-create log directory in Write-Log C:\Windows\Setup\Scripts\ does not exist on a fresh Windows install. Add New-Item -Force before Add-Content so the first log write creates the directory automatically. Co-Authored-By: Claude Sonnet 4.6 --- scripts/00-admin-account.ps1 | 1 + scripts/01-bloatware.ps1 | 1 + scripts/02-software.ps1 | 1 + scripts/03-system-registry.ps1 | 1 + scripts/04-default-profile.ps1 | 1 + scripts/05-personalization.ps1 | 1 + scripts/06-scheduled-tasks.ps1 | 1 + scripts/07-backinfo.ps1 | 1 + scripts/07-desktop-info.ps1 | 1 + scripts/08-activation.ps1 | 1 + scripts/09-pc-identity.ps1 | 1 + scripts/10-network.ps1 | 1 + scripts/11-dell-update.ps1 | 1 + 13 files changed, 13 insertions(+) diff --git a/scripts/00-admin-account.ps1 b/scripts/00-admin-account.ps1 index bca037d..82d9bb3 100644 --- a/scripts/00-admin-account.ps1 +++ b/scripts/00-admin-account.ps1 @@ -27,6 +27,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/01-bloatware.ps1 b/scripts/01-bloatware.ps1 index 7b45b67..fe9108b 100644 --- a/scripts/01-bloatware.ps1 +++ b/scripts/01-bloatware.ps1 @@ -23,6 +23,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/02-software.ps1 b/scripts/02-software.ps1 index d6176f5..3385db3 100644 --- a/scripts/02-software.ps1 +++ b/scripts/02-software.ps1 @@ -28,6 +28,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/03-system-registry.ps1 b/scripts/03-system-registry.ps1 index 8f7e290..f62d5aa 100644 --- a/scripts/03-system-registry.ps1 +++ b/scripts/03-system-registry.ps1 @@ -37,6 +37,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/04-default-profile.ps1 b/scripts/04-default-profile.ps1 index fd08f7b..40d8eee 100644 --- a/scripts/04-default-profile.ps1 +++ b/scripts/04-default-profile.ps1 @@ -36,6 +36,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/05-personalization.ps1 b/scripts/05-personalization.ps1 index 9d69fd3..16b79c8 100644 --- a/scripts/05-personalization.ps1 +++ b/scripts/05-personalization.ps1 @@ -26,6 +26,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/06-scheduled-tasks.ps1 b/scripts/06-scheduled-tasks.ps1 index ca8c879..304c6ee 100644 --- a/scripts/06-scheduled-tasks.ps1 +++ b/scripts/06-scheduled-tasks.ps1 @@ -23,6 +23,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/07-backinfo.ps1 b/scripts/07-backinfo.ps1 index 1303165..eacae46 100644 --- a/scripts/07-backinfo.ps1 +++ b/scripts/07-backinfo.ps1 @@ -25,6 +25,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/07-desktop-info.ps1 b/scripts/07-desktop-info.ps1 index e188773..5aa6f7f 100644 --- a/scripts/07-desktop-info.ps1 +++ b/scripts/07-desktop-info.ps1 @@ -25,6 +25,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/08-activation.ps1 b/scripts/08-activation.ps1 index 8a87281..e8c8013 100644 --- a/scripts/08-activation.ps1 +++ b/scripts/08-activation.ps1 @@ -26,6 +26,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/09-pc-identity.ps1 b/scripts/09-pc-identity.ps1 index b353fac..17f71c3 100644 --- a/scripts/09-pc-identity.ps1 +++ b/scripts/09-pc-identity.ps1 @@ -26,6 +26,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/10-network.ps1 b/scripts/10-network.ps1 index e453ec0..3c33582 100644 --- a/scripts/10-network.ps1 +++ b/scripts/10-network.ps1 @@ -24,6 +24,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 } diff --git a/scripts/11-dell-update.ps1 b/scripts/11-dell-update.ps1 index ed17d67..b4928fd 100644 --- a/scripts/11-dell-update.ps1 +++ b/scripts/11-dell-update.ps1 @@ -26,6 +26,7 @@ $ErrorActionPreference = "Continue" function Write-Log { param([string]$Message, [string]$Level = "INFO") $line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message" + $null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue Add-Content -Path $LogFile -Value $line -Encoding UTF8 switch ($Level) { "OK" { Write-Host $line -ForegroundColor Green }