Update gasten.txt, medewerkers.txt, get-serial.bat, and 12 more files
This commit is contained in:
1 parent
7e3a8bced6
commit
14dae8eb8e
10 files changed
+738
-112
No files matched your search
@@ -0,0 +1,40 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo Retrieving laptop serial number...
|
||||
|
||||
:: Gebruik een aparte map in de root als uitvoerlocatie
|
||||
set "output_dir=%~dp0..\output"
|
||||
:: Maak de output map aan als deze niet bestaat
|
||||
if not exist "!output_dir!" mkdir "!output_dir!"
|
||||
echo Uitvoerlocatie: !output_dir!
|
||||
|
||||
:: Get the serial number using PowerShell instead of WMIC
|
||||
for /f "delims=" %%a in ('powershell -command "(Get-WmiObject -Class Win32_BIOS).SerialNumber"') do (
|
||||
set "serial=%%a"
|
||||
)
|
||||
|
||||
:: Remove any spaces from the serial number
|
||||
set "serial=!serial: =!"
|
||||
|
||||
:: Check if serial number was found
|
||||
if "!serial!"=="" (
|
||||
echo Error: Could not retrieve serial number.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Get the hostname
|
||||
set "hostname=%COMPUTERNAME%"
|
||||
|
||||
:: Create a text file with HOSTNAME_SERIAL as the filename
|
||||
set "filename=!hostname!_!serial!.txt"
|
||||
echo Serial Number: !serial! > "!output_dir!\!filename!"
|
||||
echo Computer Name: !hostname! >> "!output_dir!\!filename!"
|
||||
echo Date: %DATE% >> "!output_dir!\!filename!"
|
||||
echo Time: %TIME% >> "!output_dir!\!filename!"
|
||||
|
||||
echo Serial number !serial! has been saved to !output_dir!\!filename!
|
||||
echo.
|
||||
echo Script completed successfully.
|
||||
pause
|
||||
endlocal
|
||||
@@ -0,0 +1,147 @@
|
||||
# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B
|
||||
|
||||
# Check and install dependencies if needed
|
||||
Write-Host "Controleer dependencies..." -ForegroundColor Yellow
|
||||
|
||||
# Check if winget is available
|
||||
try {
|
||||
$wingetVersion = winget --version 2>$null
|
||||
if ($wingetVersion) {
|
||||
Write-Host "winget is beschikbaar: $wingetVersion" -ForegroundColor Green
|
||||
} else {
|
||||
throw "winget niet gevonden"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "winget niet gevonden. Probeer te installeren..." -ForegroundColor Red
|
||||
|
||||
# Try to install winget from Microsoft Store
|
||||
try {
|
||||
Write-Host "Installeer winget via Microsoft Store..." -ForegroundColor Yellow
|
||||
Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1" -Wait
|
||||
Write-Host "Controleer of winget nu beschikbaar is..." -ForegroundColor Yellow
|
||||
|
||||
# Wait a bit and check again
|
||||
Start-Sleep -Seconds 5
|
||||
$wingetVersion = winget --version 2>$null
|
||||
if ($wingetVersion) {
|
||||
Write-Host "winget succesvol geïnstalleerd: $wingetVersion" -ForegroundColor Green
|
||||
} else {
|
||||
throw "winget installatie mislukt"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Automatische winget installatie mislukt. Probeer handmatig:" -ForegroundColor Red
|
||||
Write-Host "1. Open Microsoft Store" -ForegroundColor White
|
||||
Write-Host "2. Zoek naar 'App Installer'" -ForegroundColor White
|
||||
Write-Host "3. Installeer de App Installer" -ForegroundColor White
|
||||
Write-Host "4. Herstart PowerShell en voer dit script opnieuw uit" -ForegroundColor White
|
||||
Read-Host "Druk op Enter om af te sluiten"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Check if running as administrator
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
|
||||
if (-not $isAdmin) {
|
||||
Write-Host "Dit script moet als Administrator worden uitgevoerd voor machine-wide installaties." -ForegroundColor Red
|
||||
Write-Host "Start PowerShell opnieuw als Administrator en voer dit script opnieuw uit." -ForegroundColor Yellow
|
||||
Read-Host "Druk op Enter om af te sluiten"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Alle dependencies zijn beschikbaar. Start met app installaties..." -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Install apps
|
||||
Write-Host "Bepaal gebruikerstype en laad app lijst..." -ForegroundColor Yellow
|
||||
|
||||
# Determine user type and load appropriate app list
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$parentDir = Split-Path -Parent $scriptDir
|
||||
$medewerkersFile = Join-Path $parentDir "apps\medewerkers.txt"
|
||||
$gastenFile = Join-Path $parentDir "apps\gasten.txt"
|
||||
|
||||
# Check if user is a medewerker (has specific group membership or file exists)
|
||||
$isMedewerker = $false
|
||||
$isGast = $false
|
||||
|
||||
# Try to determine user type - you can customize this logic
|
||||
try {
|
||||
# Check if user is in specific AD groups (customize as needed)
|
||||
$userGroups = (Get-ADUser -Identity $env:USERNAME -Properties MemberOf).MemberOf
|
||||
if ($userGroups -match "Medewerkers|Employees|Staff") {
|
||||
$isMedewerker = $true
|
||||
Write-Host "Gebruiker gedetecteerd als medewerker" -ForegroundColor Green
|
||||
} else {
|
||||
$isGast = $true
|
||||
Write-Host "Gebruiker gedetecteerd als gast" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
# Fallback: ask user to choose
|
||||
Write-Host "Kon gebruikerstype niet automatisch bepalen." -ForegroundColor Yellow
|
||||
Write-Host "1. Medewerker" -ForegroundColor White
|
||||
Write-Host "2. Gast" -ForegroundColor White
|
||||
do {
|
||||
$choice = Read-Host "Kies gebruikerstype (1 of 2)"
|
||||
} while ($choice -notin @("1", "2"))
|
||||
|
||||
if ($choice -eq "1") {
|
||||
$isMedewerker = $true
|
||||
} else {
|
||||
$isGast = $true
|
||||
}
|
||||
}
|
||||
|
||||
# Load appropriate app list
|
||||
$appsFile = if ($isMedewerker) { $medewerkersFile } else { $gastenFile }
|
||||
$userType = if ($isMedewerker) { "medewerker" } else { "gast" }
|
||||
|
||||
Write-Host "Gebruikerstype: $userType" -ForegroundColor Cyan
|
||||
Write-Host "App lijst: $appsFile" -ForegroundColor Cyan
|
||||
|
||||
# Check if app file exists
|
||||
if (-not (Test-Path $appsFile)) {
|
||||
Write-Host "Fout: App lijst niet gevonden: $appsFile" -ForegroundColor Red
|
||||
Read-Host "Druk op Enter om af te sluiten"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Load apps from file
|
||||
try {
|
||||
Write-Host "Laad app lijst..." -ForegroundColor Yellow
|
||||
. $appsFile
|
||||
Write-Host "✓ App lijst geladen: $($apps.Count) apps gevonden" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "Fout bij laden van app lijst: $($_.Exception.Message)" -ForegroundColor Red
|
||||
Read-Host "Druk op Enter om af te sluiten"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ($apps.Count -eq 0) {
|
||||
Write-Host "Geen apps gevonden in de lijst!" -ForegroundColor Red
|
||||
Read-Host "Druk op Enter om af te sluiten"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Start installatie van $($apps.Count) apps voor $userType..." -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
$totalApps = $apps.Count
|
||||
$currentApp = 0
|
||||
|
||||
foreach ($app in $apps) {
|
||||
$currentApp++
|
||||
Write-Host "[$currentApp/$totalApps] Installeer $app..." -ForegroundColor Cyan
|
||||
|
||||
try {
|
||||
Start-Process -NoNewWindow -Wait -FilePath "winget" -ArgumentList "install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine"
|
||||
Write-Host "✓ $app succesvol geïnstalleerd" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "✗ Fout bij installatie van $app" -ForegroundColor Red
|
||||
Write-Host "Foutdetails: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Write-Host "App installatie voltooid!" -ForegroundColor Green
|
||||
Read-Host "Druk op Enter om af te sluiten"
|
||||
@@ -0,0 +1,43 @@
|
||||
# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B
|
||||
|
||||
# URL of the image
|
||||
$imageUrl = "https://hibbit.cloud/hho/background.jpg"
|
||||
|
||||
# Create temp directory if it doesn't exist
|
||||
$tempDir = "$env:TEMP\wallpaper"
|
||||
if (-not (Test-Path $tempDir)) {
|
||||
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
|
||||
}
|
||||
|
||||
# Download the image
|
||||
$wallpaperPath = "$tempDir\background.jpg"
|
||||
Write-Host "Downloading wallpaper..." -ForegroundColor Yellow
|
||||
try {
|
||||
Invoke-WebRequest -Uri $imageUrl -OutFile $wallpaperPath -TimeoutSec 60
|
||||
Write-Host "Download complete!" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Error "Failed to download wallpaper: $_"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Set the wallpaper
|
||||
try {
|
||||
$code = @'
|
||||
using System.Runtime.InteropServices;
|
||||
public class Wallpaper {
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
|
||||
}
|
||||
'@
|
||||
|
||||
Add-Type -TypeDefinition $code
|
||||
$SPI_SETDESKWALLPAPER = 0x0014
|
||||
$SPIF_UPDATEINIFILE = 0x01
|
||||
$SPIF_SENDCHANGE = 0x02
|
||||
|
||||
[Wallpaper]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $wallpaperPath, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE)
|
||||
Write-Host "Wallpaper set successfully!" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Error "Failed to set wallpaper: $_"
|
||||
exit 1
|
||||
}
|
||||
@@ -0,0 +1,472 @@
|
||||
# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B
|
||||
|
||||
# =============================================================================
|
||||
# COMPLETE SYSTEM UPDATE SCRIPT
|
||||
# Dit script installeert en update alle applicaties, drivers en Windows updates
|
||||
# =============================================================================
|
||||
|
||||
# Functie voor logging
|
||||
function Write-Log {
|
||||
param(
|
||||
[string]$Message,
|
||||
[string]$Level = "INFO"
|
||||
)
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
$logMessage = "[$timestamp] [$Level] $Message"
|
||||
Write-Host $logMessage
|
||||
|
||||
# Log ook naar bestand
|
||||
try {
|
||||
# Probeer verschillende methoden om het script pad te bepalen
|
||||
$scriptPath = $null
|
||||
|
||||
# Methode 1: Via $MyInvocation
|
||||
if ($MyInvocation.ScriptName) {
|
||||
$scriptPath = Split-Path -Parent $MyInvocation.ScriptName
|
||||
}
|
||||
|
||||
# Methode 2: Via $PSCommandPath
|
||||
if (-not $scriptPath -and $PSCommandPath) {
|
||||
$scriptPath = Split-Path -Parent $PSCommandPath
|
||||
}
|
||||
|
||||
# Methode 3: Via $PSScriptRoot
|
||||
if (-not $scriptPath -and $PSScriptRoot) {
|
||||
$scriptPath = $PSScriptRoot
|
||||
}
|
||||
|
||||
# Methode 4: Fallback naar huidige directory
|
||||
if (-not $scriptPath) {
|
||||
$scriptPath = Get-Location
|
||||
}
|
||||
|
||||
$logFile = Join-Path $scriptPath "update-log.txt"
|
||||
Add-Content -Path $logFile -Value $logMessage -ErrorAction SilentlyContinue
|
||||
} catch {
|
||||
# Als alles faalt, probeer gewoon in de huidige directory
|
||||
try {
|
||||
Add-Content -Path "update-log.txt" -Value $logMessage -ErrorAction SilentlyContinue
|
||||
} catch {
|
||||
# Laatste fallback - geen logging naar bestand
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Functie voor voortgangsindicator
|
||||
function Show-Progress {
|
||||
param(
|
||||
[string]$Activity,
|
||||
[string]$Status,
|
||||
[int]$PercentComplete
|
||||
)
|
||||
Write-Progress -Activity $Activity -Status $Status -PercentComplete $PercentComplete
|
||||
}
|
||||
|
||||
# Functie om te controleren of een commando bestaat
|
||||
function Test-Command {
|
||||
param([string]$Command)
|
||||
try {
|
||||
Get-Command $Command -ErrorAction Stop | Out-Null
|
||||
return $true
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# Functie om te wachten op gebruiker input
|
||||
function Wait-ForUser {
|
||||
param([string]$Message = "Druk op Enter om door te gaan...")
|
||||
Write-Host $Message -ForegroundColor Yellow
|
||||
Read-Host
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# HOOFDSCRIPT START
|
||||
# =============================================================================
|
||||
|
||||
Write-Host "================================================" -ForegroundColor Cyan
|
||||
Write-Host " COMPLETE SYSTEM UPDATE SCRIPT" -ForegroundColor Cyan
|
||||
Write-Host " Alle applicaties, drivers en Windows updates" -ForegroundColor Cyan
|
||||
Write-Host "================================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
Write-Log "Script gestart" "INFO"
|
||||
|
||||
# Controleer administrator rechten
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
|
||||
if (-not $isAdmin) {
|
||||
Write-Log "Script moet als Administrator worden uitgevoerd" "ERROR"
|
||||
Write-Host "Dit script moet als Administrator worden uitgevoerd!" -ForegroundColor Red
|
||||
Write-Host "Start PowerShell opnieuw als Administrator en voer dit script opnieuw uit." -ForegroundColor Yellow
|
||||
Wait-ForUser
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Log "Administrator rechten bevestigd" "INFO"
|
||||
|
||||
# =============================================================================
|
||||
# STAP 1: DEPENDENCY CONTROLES
|
||||
# =============================================================================
|
||||
|
||||
Write-Host "STAP 1: Controleer dependencies..." -ForegroundColor Green
|
||||
Show-Progress -Activity "Dependency Controle" -Status "Controleer winget..." -PercentComplete 10
|
||||
|
||||
# Controleer winget
|
||||
try {
|
||||
$wingetVersion = winget --version 2>$null
|
||||
if ($wingetVersion) {
|
||||
Write-Log "winget is beschikbaar: $wingetVersion" "INFO"
|
||||
Write-Host "✓ winget is beschikbaar: $wingetVersion" -ForegroundColor Green
|
||||
} else {
|
||||
throw "winget niet gevonden"
|
||||
}
|
||||
} catch {
|
||||
Write-Log "winget niet gevonden, probeer te installeren" "WARNING"
|
||||
Write-Host "⚠ winget niet gevonden. Probeer te installeren..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
Write-Host "Installeer winget via Microsoft Store..." -ForegroundColor Yellow
|
||||
Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1" -Wait -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 5
|
||||
|
||||
$wingetVersion = winget --version 2>$null
|
||||
if ($wingetVersion) {
|
||||
Write-Log "winget succesvol geïnstalleerd: $wingetVersion" "INFO"
|
||||
Write-Host "✓ winget succesvol geïnstalleerd: $wingetVersion" -ForegroundColor Green
|
||||
} else {
|
||||
throw "winget installatie mislukt"
|
||||
}
|
||||
} catch {
|
||||
Write-Log "winget installatie mislukt" "ERROR"
|
||||
Write-Host "✗ Automatische winget installatie mislukt." -ForegroundColor Red
|
||||
Write-Host "Probeer handmatig:" -ForegroundColor White
|
||||
Write-Host "1. Open Microsoft Store" -ForegroundColor White
|
||||
Write-Host "2. Zoek naar 'App Installer'" -ForegroundColor White
|
||||
Write-Host "3. Installeer de App Installer" -ForegroundColor White
|
||||
Wait-ForUser
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Controleer Windows Update service
|
||||
Show-Progress -Activity "Dependency Controle" -Status "Controleer Windows Update service..." -PercentComplete 20
|
||||
try {
|
||||
$wuService = Get-Service -Name "wuauserv" -ErrorAction SilentlyContinue
|
||||
if ($wuService -and $wuService.Status -ne "Running") {
|
||||
Write-Log "Start Windows Update service" "INFO"
|
||||
Start-Service -Name "wuauserv" -ErrorAction SilentlyContinue
|
||||
Write-Host "✓ Windows Update service gestart" -ForegroundColor Green
|
||||
} elseif ($wuService) {
|
||||
Write-Host "✓ Windows Update service is actief" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "⚠ Windows Update service niet beschikbaar" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
Write-Log "Windows Update service probleem" "WARNING"
|
||||
Write-Host "⚠ Windows Update service probleem" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# STAP 2: WINDOWS UPDATES
|
||||
# =============================================================================
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "STAP 2: Windows Updates..." -ForegroundColor Green
|
||||
Show-Progress -Activity "Windows Updates" -Status "Controleer beschikbare updates..." -PercentComplete 30
|
||||
|
||||
try {
|
||||
Write-Log "Start Windows Update controle" "INFO"
|
||||
Write-Host "Controleer beschikbare Windows updates..." -ForegroundColor Cyan
|
||||
|
||||
# Controleer updates
|
||||
$updateSession = New-Object -ComObject Microsoft.Update.Session -ErrorAction SilentlyContinue
|
||||
if ($updateSession) {
|
||||
$updateSearcher = $updateSession.CreateUpdateSearcher()
|
||||
$searchResult = $updateSearcher.Search("IsInstalled=0")
|
||||
|
||||
if ($searchResult.Updates.Count -gt 0) {
|
||||
Write-Host "✓ $($searchResult.Updates.Count) Windows updates gevonden" -ForegroundColor Green
|
||||
Write-Log "Gevonden $($searchResult.Updates.Count) Windows updates" "INFO"
|
||||
|
||||
# Toon details van elke update
|
||||
Write-Host "Gevonden updates:" -ForegroundColor Cyan
|
||||
for ($i = 0; $i -lt $searchResult.Updates.Count; $i++) {
|
||||
$update = $searchResult.Updates.Item($i)
|
||||
$updateNumber = $i + 1
|
||||
$kbNumber = "KB" + $update.KBArticleIDs.Item(0)
|
||||
Write-Host "$updateNumber. $kbNumber - $($update.Title)" -ForegroundColor White
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
# Download en installeer updates
|
||||
Show-Progress -Activity "Windows Updates" -Status "Download en installeer updates..." -PercentComplete 40
|
||||
|
||||
$updatesToDownload = New-Object -ComObject Microsoft.Update.UpdateColl
|
||||
foreach ($update in $searchResult.Updates) {
|
||||
if ($update.IsDownloaded -eq $false) {
|
||||
$updatesToDownload.Add($update)
|
||||
}
|
||||
}
|
||||
|
||||
if ($updatesToDownload.Count -gt 0) {
|
||||
Write-Host "Download $($updatesToDownload.Count) updates..." -ForegroundColor Cyan
|
||||
$downloader = $updateSession.CreateUpdateDownloader()
|
||||
$downloader.Updates = $updatesToDownload
|
||||
$downloadResult = $downloader.Download()
|
||||
|
||||
if ($downloadResult.ResultCode -eq 2) {
|
||||
Write-Host "✓ Updates succesvol gedownload" -ForegroundColor Green
|
||||
Write-Log "Windows updates gedownload" "INFO"
|
||||
} else {
|
||||
Write-Host "⚠ Download gedeeltelijk voltooid" -ForegroundColor Yellow
|
||||
Write-Log "Windows updates gedeeltelijk gedownload" "WARNING"
|
||||
}
|
||||
}
|
||||
|
||||
# Installeer updates
|
||||
$updatesToInstall = New-Object -ComObject Microsoft.Update.UpdateColl
|
||||
foreach ($update in $searchResult.Updates) {
|
||||
if ($update.IsDownloaded -eq $true) {
|
||||
$updatesToInstall.Add($update)
|
||||
}
|
||||
}
|
||||
|
||||
if ($updatesToInstall.Count -gt 0) {
|
||||
Write-Host "Installeer $($updatesToInstall.Count) updates..." -ForegroundColor Cyan
|
||||
$installer = $updateSession.CreateUpdateInstaller()
|
||||
$installer.Updates = $updatesToInstall
|
||||
$installResult = $installer.Install()
|
||||
|
||||
if ($installResult.ResultCode -eq 2) {
|
||||
Write-Host "✓ Windows updates succesvol geïnstalleerd" -ForegroundColor Green
|
||||
Write-Log "Windows updates geïnstalleerd" "INFO"
|
||||
} else {
|
||||
Write-Host "⚠ Installatie gedeeltelijk voltooid" -ForegroundColor Yellow
|
||||
Write-Log "Windows updates gedeeltelijk geïnstalleerd" "WARNING"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Write-Host "✓ Geen Windows updates beschikbaar" -ForegroundColor Green
|
||||
Write-Log "Geen Windows updates beschikbaar" "INFO"
|
||||
}
|
||||
} else {
|
||||
Write-Host "⚠ Windows Update service niet beschikbaar" -ForegroundColor Yellow
|
||||
Write-Log "Windows Update service niet beschikbaar" "WARNING"
|
||||
}
|
||||
} catch {
|
||||
Write-Log "Windows Update fout" "ERROR"
|
||||
Write-Host "✗ Fout bij Windows updates" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# STAP 3: DRIVER UPDATES
|
||||
# =============================================================================
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "STAP 3: Driver Updates..." -ForegroundColor Green
|
||||
Show-Progress -Activity "Driver Updates" -Status "Controleer driver updates..." -PercentComplete 50
|
||||
|
||||
# Dell Command Update (als beschikbaar)
|
||||
if (Test-Command "DellCommandUpdate") {
|
||||
try {
|
||||
Write-Host "Controleer Dell driver updates..." -ForegroundColor Cyan
|
||||
Write-Log "Start Dell Command Update" "INFO"
|
||||
|
||||
# Voer Dell Command Update uit
|
||||
$dellProcess = Start-Process -FilePath "DellCommandUpdate" -ArgumentList "/silent" -PassThru -Wait -ErrorAction SilentlyContinue
|
||||
if ($dellProcess -and $dellProcess.ExitCode -eq 0) {
|
||||
Write-Host "✓ Dell driver updates voltooid" -ForegroundColor Green
|
||||
Write-Log "Dell driver updates voltooid" "INFO"
|
||||
} else {
|
||||
Write-Host "⚠ Dell driver updates gedeeltelijk voltooid" -ForegroundColor Yellow
|
||||
Write-Log "Dell driver updates gedeeltelijk voltooid" "WARNING"
|
||||
}
|
||||
} catch {
|
||||
Write-Log "Dell Command Update fout" "ERROR"
|
||||
Write-Host "✗ Fout bij Dell driver updates" -ForegroundColor Red
|
||||
}
|
||||
} else {
|
||||
Write-Host "⚠ Dell Command Update niet gevonden" -ForegroundColor Yellow
|
||||
Write-Log "Dell Command Update niet beschikbaar" "WARNING"
|
||||
}
|
||||
|
||||
# Windows Driver Updates via winget
|
||||
try {
|
||||
Write-Host "Controleer Windows driver updates via winget..." -ForegroundColor Cyan
|
||||
Show-Progress -Activity "Driver Updates" -Status "Update drivers via winget..." -PercentComplete 60
|
||||
|
||||
# Zoek naar driver updates
|
||||
$driverUpdates = winget upgrade --source winget --include-unknown 2>$null | Select-String "driver|Driver"
|
||||
|
||||
if ($driverUpdates) {
|
||||
Write-Host "✓ Driver updates gevonden via winget" -ForegroundColor Green
|
||||
Write-Log "Driver updates gevonden via winget" "INFO"
|
||||
|
||||
# Installeer driver updates
|
||||
winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown 2>$null
|
||||
Write-Host "✓ Driver updates geïnstalleerd" -ForegroundColor Green
|
||||
Write-Log "Driver updates geïnstalleerd via winget" "INFO"
|
||||
} else {
|
||||
Write-Host "✓ Geen driver updates beschikbaar via winget" -ForegroundColor Green
|
||||
Write-Log "Geen driver updates beschikbaar via winget" "INFO"
|
||||
}
|
||||
} catch {
|
||||
Write-Log "Driver update fout" "ERROR"
|
||||
Write-Host "✗ Fout bij driver updates" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# STAP 4: APPLICATIE UPDATES
|
||||
# =============================================================================
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "STAP 4: Applicatie Updates..." -ForegroundColor Green
|
||||
Show-Progress -Activity "Applicatie Updates" -Status "Update alle applicaties..." -PercentComplete 70
|
||||
|
||||
try {
|
||||
Write-Host "Controleer beschikbare applicatie updates..." -ForegroundColor Cyan
|
||||
Write-Log "Start applicatie updates via winget" "INFO"
|
||||
|
||||
# Controleer eerst welke updates beschikbaar zijn
|
||||
Write-Host "Zoek naar beschikbare updates..." -ForegroundColor Yellow
|
||||
$availableUpdates = winget upgrade --source winget --include-unknown 2>$null
|
||||
|
||||
if ($availableUpdates -and $availableUpdates -match "No applicable updates found" -eq $false) {
|
||||
# Parse de output om updates te vinden
|
||||
$updateLines = $availableUpdates | Where-Object { $_ -match "^\w+\." -and $_ -notmatch "No applicable updates found" }
|
||||
|
||||
if ($updateLines.Count -gt 0) {
|
||||
Write-Host "✓ $($updateLines.Count) applicatie updates gevonden" -ForegroundColor Green
|
||||
Write-Log "Gevonden $($updateLines.Count) applicatie updates" "INFO"
|
||||
|
||||
# Toon details van elke update
|
||||
Write-Host "Gevonden applicatie updates:" -ForegroundColor Cyan
|
||||
$updateNumber = 1
|
||||
foreach ($line in $updateLines) {
|
||||
if ($line -match "^\w+\.") {
|
||||
# Parse de regel om app naam en versie te extraheren
|
||||
$parts = $line -split "\s+"
|
||||
if ($parts.Count -ge 3) {
|
||||
$appName = $parts[0]
|
||||
$currentVersion = $parts[1]
|
||||
$newVersion = $parts[2]
|
||||
Write-Host "$updateNumber. $appName ($currentVersion → $newVersion)" -ForegroundColor White
|
||||
$updateNumber++
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Host ""
|
||||
} else {
|
||||
Write-Host "✓ Geen applicatie updates beschikbaar" -ForegroundColor Green
|
||||
Write-Log "Geen applicatie updates beschikbaar" "INFO"
|
||||
}
|
||||
} else {
|
||||
Write-Host "✓ Geen applicatie updates beschikbaar" -ForegroundColor Green
|
||||
Write-Log "Geen applicatie updates beschikbaar" "INFO"
|
||||
}
|
||||
|
||||
# Voer winget upgrade uit voor alle applicaties
|
||||
Write-Host "Update alle applicaties via winget..." -ForegroundColor Cyan
|
||||
$upgradeResult = winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown 2>$null
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✓ Alle applicaties succesvol geüpdatet" -ForegroundColor Green
|
||||
Write-Log "Applicatie updates voltooid" "INFO"
|
||||
} else {
|
||||
Write-Host "⚠ Applicatie updates gedeeltelijk voltooid" -ForegroundColor Yellow
|
||||
Write-Log "Applicatie updates gedeeltelijk voltooid" "WARNING"
|
||||
}
|
||||
} catch {
|
||||
Write-Log "Applicatie update fout" "ERROR"
|
||||
Write-Host "✗ Fout bij applicatie updates" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# STAP 5: SYSTEEM OPTIMALISATIE
|
||||
# =============================================================================
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "STAP 5: Systeem Optimalisatie..." -ForegroundColor Green
|
||||
Show-Progress -Activity "Systeem Optimalisatie" -Status "Voer systeem optimalisatie uit..." -PercentComplete 80
|
||||
|
||||
try {
|
||||
Write-Host "Voer systeem optimalisatie uit..." -ForegroundColor Cyan
|
||||
Write-Log "Start systeem optimalisatie" "INFO"
|
||||
|
||||
# Schoon Windows Update cache
|
||||
Write-Host "Schoon Windows Update cache..." -ForegroundColor Yellow
|
||||
Stop-Service -Name "wuauserv" -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item -Path "$env:SystemRoot\SoftwareDistribution\Download\*" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Start-Service -Name "wuauserv" -ErrorAction SilentlyContinue
|
||||
Write-Host "✓ Windows Update cache opgeschoond" -ForegroundColor Green
|
||||
|
||||
# Schoon temp bestanden
|
||||
Write-Host "Schoon temp bestanden..." -ForegroundColor Yellow
|
||||
Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "✓ Temp bestanden opgeschoond" -ForegroundColor Green
|
||||
|
||||
# Voer DISM health check uit
|
||||
Write-Host "Voer DISM health check uit..." -ForegroundColor Yellow
|
||||
DISM /Online /Cleanup-Image /CheckHealth /NoRestart 2>$null | Out-Null
|
||||
DISM /Online /Cleanup-Image /ScanHealth /NoRestart 2>$null | Out-Null
|
||||
Write-Host "✓ DISM health check voltooid" -ForegroundColor Green
|
||||
|
||||
Write-Log "Systeem optimalisatie voltooid" "INFO"
|
||||
} catch {
|
||||
Write-Log "Systeem optimalisatie fout" "ERROR"
|
||||
Write-Host "✗ Fout bij systeem optimalisatie" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
# VOLTOOIING
|
||||
# =============================================================================
|
||||
|
||||
Show-Progress -Activity "Update Proces" -Status "Voltooid!" -PercentComplete 100
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "================================================" -ForegroundColor Green
|
||||
Write-Host " UPDATE PROCES VOLTOOID!" -ForegroundColor Green
|
||||
Write-Host "================================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
Write-Log "Update proces voltooid" "INFO"
|
||||
|
||||
Write-Host "Samenvatting:" -ForegroundColor Cyan
|
||||
Write-Host "✓ Windows Updates gecontroleerd en geïnstalleerd" -ForegroundColor Green
|
||||
Write-Host "✓ Driver Updates gecontroleerd en geïnstalleerd" -ForegroundColor Green
|
||||
Write-Host "✓ Applicatie Updates uitgevoerd" -ForegroundColor Green
|
||||
Write-Host "✓ Systeem optimalisatie uitgevoerd" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# Bepaal log bestand locatie
|
||||
$logPath = "update-log.txt"
|
||||
try {
|
||||
if ($MyInvocation.ScriptName) {
|
||||
$scriptPath = Split-Path -Parent $MyInvocation.ScriptName
|
||||
$logPath = Join-Path $scriptPath "update-log.txt"
|
||||
} elseif ($PSCommandPath) {
|
||||
$scriptPath = Split-Path -Parent $PSCommandPath
|
||||
$logPath = Join-Path $scriptPath "update-log.txt"
|
||||
} elseif ($PSScriptRoot) {
|
||||
$logPath = Join-Path $PSScriptRoot "update-log.txt"
|
||||
}
|
||||
} catch {
|
||||
# Fallback naar huidige directory
|
||||
}
|
||||
|
||||
Write-Host "Log bestand opgeslagen in: $logPath" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
# Vraag of gebruiker wil herstarten
|
||||
$restart = Read-Host "Wil je de computer nu herstarten? (j/n)"
|
||||
if ($restart -eq "j" -or $restart -eq "J" -or $restart -eq "y" -or $restart -eq "Y") {
|
||||
Write-Host "Computer wordt herstart in 10 seconden..." -ForegroundColor Yellow
|
||||
Write-Log "Computer herstart gepland" "INFO"
|
||||
Start-Sleep -Seconds 10
|
||||
Restart-Computer -Force
|
||||
} else {
|
||||
Write-Host "Herstart later handmatig om alle updates volledig toe te passen." -ForegroundColor Yellow
|
||||
Wait-ForUser
|
||||
}
|
||||
|
||||
Write-Log "Script beëindigd" "INFO"
|
||||
@@ -0,0 +1,27 @@
|
||||
@echo off
|
||||
:: Controleer op administrator rechten
|
||||
net session >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo Administrator rechten zijn vereist. Start het script opnieuw als administrator.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Starting application updates...
|
||||
echo.
|
||||
|
||||
:: Controleer of Winget is geïnstalleerd
|
||||
where winget >nul 2>nul
|
||||
if %errorlevel% neq 0 (
|
||||
echo Winget is niet geïnstalleerd. Installeer eerst de App Installer vanuit de Microsoft Store.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Voer winget upgrade uit voor alle applicaties
|
||||
winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown
|
||||
|
||||
echo.
|
||||
echo Update proces is voltooid.
|
||||
echo Druk op een toets om af te sluiten...
|
||||
pause >nul
|
||||
Reference in new issue
Block a user