Update gasten.txt, medewerkers.txt, get-serial.bat, and 12 more files

This commit is contained in:
rogier committed 2025-10-12 11:14:15 +02:00
1 parent 7e3a8bced6
commit 14dae8eb8e
10 files changed
+738 -112

No files matched your search

+118 -47
View File
@@ -1,47 +1,118 @@
# PowerShell & CMD Scripts
Deze repository bevat een verzameling handige scripts voor het beheren van een Windows-systeem.
## Inhoudsopgave
- [PowerShell & CMD Scripts](#powershell--cmd-scripts)
- [Inhoudsopgave](#inhoudsopgave)
- [Scripts](#scripts)
- [install-apps.cmd](#install-appscmd)
- [install-background.cmd](#install-backgroundcmd)
- [get-serial.bat](#get-serialbat)
- [update-all.cmd](#update-allcmd)
- [update-apps.cmd](#update-appscmd)
## Scripts
### install-apps.cmd
Dit script installeert een vooraf gedefinieerde lijst van essentiële applicaties met behulp van `winget`. Het controleert eerst of `winget` is geïnstalleerd en of het script met administratorrechten wordt uitgevoerd.
De volgende applicaties worden geïnstalleeerd:
- .NET Desktop Runtime 8
- Google Chrome
- Google Drive
- Chrome Remote Desktop Host
- Dell Command Update
- Logitech Options+
- Notepad++
### install-background.cmd
Dit script downloadt een afbeelding van een specifieke URL en stelt deze in als bureaubladachtergrond.
### get-serial.bat
Dit batchscript haalt het serienummer en de hostnaam van de computer op. Vervolgens wordt deze informatie opgeslagen in een tekstbestand met de naam `HOSTNAME_SERIENUMMER.txt` in dezelfde map als het script.
### update-all.cmd
Een uitgebreid script dat een volledige systeemupdate uitvoert. Het script doorloopt de volgende stappen:
1. **Controle van dependencies**: Verifieert of `winget` beschikbaar is.
2. **Windows Updates**: Zoekt en installeert de nieuwste Windows-updates.
3. **Driver Updates**: Werkt stuurprogramma's bij via Dell Command Update (indien beschikbaar) en `winget`.
4. **Applicatie Updates**: Werkt alle geïnstalleerde applicaties bij met `winget`.
5. **Installatie Essentiële Applicaties**: Installeert dezelfde lijst applicaties als `apps.cmd` als ze nog niet aanwezig zijn.
6. **Systeemoptimalisatie**: Voert optimalisatietaken uit, zoals het opschonen van caches en het uitvoeren van DISM-controles.
7. **Herstart**: Vraagt de gebruiker om de computer opnieuw op te starten om de updates te voltooien.
### update-apps.cmd
Dit script gebruikt `winget` om alle geïnstalleerde applicaties op het systeem stilzwijgend bij te werken. Het vereist administratorrechten om correct te functioneren.
# HHO PowerShell Configuratie Menu
Dit is een alles-in-één PowerShell script dat alle verschillende configuraties voor HHO laptops combineert in een gebruiksvriendelijk menu.
## Bestanden
- `main-menu.ps1` - Het hoofdmenu PowerShell script
- `main-menu.cmd` - Batch wrapper voor eenvoudige uitvoering
- `apps/medewerkers.txt` - Lijst van apps voor medewerkers
- `apps/gasten.txt` - Lijst van apps voor gasten
- `scripts/` - Map met alle individuele scripts
## Gebruik
### Optie 1: Via Batch bestand (Aanbevolen)
Dubbelklik op `main-menu.cmd` of voer uit vanaf de command line:
```
main-menu.cmd
```
### Optie 2: Direct PowerShell
Open PowerShell als Administrator en voer uit:
```powershell
.\main-menu.ps1
```
## Menu Opties
### 1. Get Serial Number
- Haalt het serienummer van de laptop op
- Slaat het op in een tekstbestand met formaat: `HOSTNAME_SERIAL.txt`
- Bevat ook computernaam, datum en tijd
### 2. Set Background voor gebruikers en Administrator
- Downloadt de HHO achtergrondafbeelding van `https://hibbit.cloud/hho/background.jpg`
- Stelt deze in als bureaubladachtergrond voor alle gebruikers
### 3. Install Apps
Submenu met twee opties:
- **a. Medewerkers configuratie** - Installeert apps uit `apps/medewerkers.txt`
- **b. Gasten configuratie** - Installeert apps uit `apps/gasten.txt`
Beide opties:
- Controleren administrator rechten
- Controleren winget beschikbaarheid
- Installeren apps via winget met machine-wide scope
- Tonen voortgang per app
### 4. Update Apps
- Update alle geïnstalleerde applicaties via winget
- Vereist administrator rechten
- Voert `winget upgrade --all` uit
### 5. Update All (Complete systeem update)
- Voert het complete update script uit (`scripts/update-all.cmd`)
- Inclusief Windows updates, driver updates, applicatie updates en systeem optimalisatie
- Vereist administrator rechten
- Vraagt om bevestiging voordat het start
## Vereisten
- Windows PowerShell 5.1 of hoger
- Administrator rechten voor opties 3, 4 en 5
- winget (Windows Package Manager) voor app installaties en updates
- Internetverbinding voor achtergrond download en app installaties
## App Configuratie Bestanden
### medewerkers.txt
```powershell
$apps = @(
"Microsoft.DotNet.DesktopRuntime.8",
"Google.Chrome",
"Google.GoogleDrive",
"Google.ChromeRemoteDesktopHost",
"Dell.CommandUpdate",
"Logitech.OptionsPlus"
)
```
### gasten.txt
```powershell
$apps = @(
"Microsoft.DotNet.DesktopRuntime.8",
"Google.Chrome",
"Mozilla.Firefox",
"Google.Drive",
"Google.ChromeRemoteDesktopHost"
"Dell.CommandUpdate",
"Logitech.OptionsPlus",
"Notepad++.Notepad++",
"Microsoft.PowerToys",
"Sysinternals.Autologon"
)
```
## Foutafhandeling
Het script bevat uitgebreide foutafhandeling voor:
- Ontbrekende administrator rechten
- Ontbrekende winget installatie
- Netwerkfouten bij downloads
- App installatie fouten
- Ontbrekende configuratie bestanden
## Logging
- Alle belangrijke acties worden gelogd naar het scherm
- Het update-all script maakt een `update-log.txt` bestand aan
- Serial number wordt opgeslagen in een tekstbestand
## Ondersteuning
Voor vragen of problemen, controleer:
1. Of je administrator rechten hebt
2. Of winget geïnstalleerd is
3. Of je internetverbinding hebt
4. Of de configuratie bestanden bestaan en correct zijn geformatteerd
+12
View File
@@ -0,0 +1,12 @@
$apps = @(
"Microsoft.DotNet.DesktopRuntime.8",
"Google.Chrome",
"Mozilla.Firefox",
"Google.Drive",
"Google.ChromeRemoteDesktopHost"
"Dell.CommandUpdate",
"Logitech.OptionsPlus",
"Notepad++.Notepad++",
"Microsoft.PowerToys",
"Sysinternals.Autologon"
)
+8
View File
@@ -0,0 +1,8 @@
$apps = @(
"Microsoft.DotNet.DesktopRuntime.8",
"Google.Chrome",
"Google.GoogleDrive",
"Google.ChromeRemoteDesktopHost",
"Dell.CommandUpdate",
"Logitech.OptionsPlus"
)
+23
View File
@@ -0,0 +1,23 @@
@echo off
:: HHO PowerShell Configuratie Menu - Batch Wrapper
:: Dit bestand start het PowerShell hoofdmenu script
echo Starting HHO PowerShell Configuration Menu...
echo.
:: Controleer of PowerShell beschikbaar is
powershell -Command "Get-Host" >nul 2>&1
if %errorlevel% neq 0 (
echo PowerShell is niet beschikbaar op dit systeem.
echo Installeer PowerShell en probeer opnieuw.
pause
exit /b 1
)
:: Start het PowerShell script
powershell -ExecutionPolicy Bypass -File "%~dp0main-menu.ps1"
:: Pauzeer aan het einde
echo.
echo Script voltooid.
pause
+498
View File
@@ -0,0 +1,498 @@
# 2>NUL & @CLS & PUSHD "%~dp0" & "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -noProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText('%~f0')|iex" & POPD & EXIT /B
# =============================================================================
# HHO POWERSHELL CONFIGURATIE MENU
# Hoofdmenu voor alle verschillende configuraties
# =============================================================================
# Functie voor kleurrijke output
function Write-ColorText {
param(
[string]$Text,
[string]$Color = "White"
)
Write-Host $Text -ForegroundColor $Color
}
# Functie voor menu header
function Show-MenuHeader {
Clear-Host
Write-ColorText "================================================" "Cyan"
Write-ColorText " HHO POWERSHELL CONFIGURATIE MENU" "Cyan"
Write-ColorText " Alle configuratie opties op één plek" "Cyan"
Write-ColorText "================================================" "Cyan"
Write-Host ""
}
# Functie voor het hoofdmenu
function Show-MainMenu {
Write-ColorText "Hoofdmenu:" "Yellow"
Write-Host ""
Write-ColorText "1. Get Serial Number" "White"
Write-ColorText "2. Set Background voor gebruikers en Administrator" "White"
Write-ColorText "3. Install Apps" "White"
Write-ColorText "4. Update Apps" "White"
Write-ColorText "5. Update All (Complete systeem update)" "White"
Write-ColorText "0. Afsluiten" "Red"
Write-Host ""
}
# Functie voor app installatie submenu
function Show-AppInstallMenu {
Write-ColorText "App Installatie:" "Yellow"
Write-Host ""
Write-ColorText "a. Medewerkers configuratie" "White"
Write-ColorText "b. Gasten configuratie" "White"
Write-ColorText "0. Terug naar hoofdmenu" "Red"
Write-Host ""
}
# Functie om te wachten op gebruiker input
function Wait-ForUser {
param([string]$Message = "Druk op Enter om door te gaan...")
Write-Host ""
Write-ColorText $Message "Yellow"
Read-Host
}
# Functie om administrator rechten te controleren
function Test-AdministratorRights {
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
return $isAdmin
}
# Functie om winget te controleren
function Test-WingetAvailable {
try {
$wingetVersion = winget --version 2>$null
return $null -ne $wingetVersion
} catch {
return $false
}
}
# =============================================================================
# OPTIE 1: GET SERIAL NUMBER
# =============================================================================
function Get-SerialNumber {
Write-ColorText "=== GET SERIAL NUMBER ===" "Green"
Write-Host ""
try {
Write-ColorText "Retrieving laptop serial number..." "Yellow"
# Gebruik de huidige map als uitvoerlocatie
$outputDir = Split-Path -Parent $MyInvocation.ScriptName
if (-not $outputDir) {
$outputDir = Get-Location
}
Write-ColorText "Uitvoerlocatie: $outputDir" "Cyan"
# Get the serial number using PowerShell
$serial = (Get-WmiObject -Class Win32_BIOS).SerialNumber
# Remove any spaces from the serial number
$serial = $serial -replace '\s', ''
# Check if serial number was found
if ([string]::IsNullOrEmpty($serial)) {
Write-ColorText "Error: Could not retrieve serial number." "Red"
Wait-ForUser
return
}
# Get the hostname
$hostname = $env:COMPUTERNAME
# Create a text file with HOSTNAME_SERIAL as the filename
$filename = "${hostname}_${serial}.txt"
$filePath = Join-Path $outputDir $filename
# Create the file content
$fileContent = @"
Serial Number: $serial
Computer Name: $hostname
Date: $(Get-Date -Format 'dd-MM-yyyy')
Time: $(Get-Date -Format 'HH:mm:ss')
"@
# Write to file
$fileContent | Out-File -FilePath $filePath -Encoding UTF8
Write-ColorText "Serial number $serial has been saved to $filePath" "Green"
Write-Host ""
Write-ColorText "Script completed successfully." "Green"
} catch {
Write-ColorText "Error occurred: $($_.Exception.Message)" "Red"
}
Wait-ForUser
}
# =============================================================================
# OPTIE 2: SET BACKGROUND
# =============================================================================
function Set-Background {
Write-ColorText "=== SET BACKGROUND ===" "Green"
Write-Host ""
try {
# 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-ColorText "Downloading wallpaper..." "Yellow"
Invoke-WebRequest -Uri $imageUrl -OutFile $wallpaperPath -TimeoutSec 60
Write-ColorText "Download complete!" "Green"
# Set the wallpaper
$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-ColorText "Wallpaper set successfully!" "Green"
} catch {
Write-ColorText "Failed to set wallpaper: $($_.Exception.Message)" "Red"
}
Wait-ForUser
}
# =============================================================================
# OPTIE 3: INSTALL APPS
# =============================================================================
function Install-Apps {
Write-ColorText "=== INSTALL APPS ===" "Green"
Write-Host ""
# Controleer administrator rechten
if (-not (Test-AdministratorRights)) {
Write-ColorText "Dit script moet als Administrator worden uitgevoerd voor machine-wide installaties." "Red"
Write-ColorText "Start PowerShell opnieuw als Administrator en voer dit script opnieuw uit." "Yellow"
Wait-ForUser
return
}
# Controleer winget
if (-not (Test-WingetAvailable)) {
Write-ColorText "winget niet gevonden. Probeer te installeren..." "Red"
try {
Write-ColorText "Installeer winget via Microsoft Store..." "Yellow"
Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1" -Wait
Write-ColorText "Controleer of winget nu beschikbaar is..." "Yellow"
Start-Sleep -Seconds 5
if (-not (Test-WingetAvailable)) {
throw "winget installatie mislukt"
}
} catch {
Write-ColorText "Automatische winget installatie mislukt. Probeer handmatig:" "Red"
Write-ColorText "1. Open Microsoft Store" "White"
Write-ColorText "2. Zoek naar 'App Installer'" "White"
Write-ColorText "3. Installeer de App Installer" "White"
Write-ColorText "4. Herstart PowerShell en voer dit script opnieuw uit" "White"
Wait-ForUser
return
}
}
Write-ColorText "Alle dependencies zijn beschikbaar. Start met app installaties..." "Green"
Write-Host ""
# Toon submenu
do {
Show-AppInstallMenu
$choice = Read-Host "Maak uw keuze (a/b/0)"
switch ($choice.ToLower()) {
"a" {
Install-MedewerkersApps
break
}
"b" {
Install-GastenApps
break
}
"0" {
return
}
default {
Write-ColorText "Ongeldige keuze. Probeer opnieuw." "Red"
Start-Sleep -Seconds 2
}
}
} while ($choice -ne "0")
}
# Functie voor medewerkers apps
function Install-MedewerkersApps {
Write-ColorText "=== INSTALL MEDEWERKERS APPS ===" "Green"
Write-Host ""
# Lees apps uit medewerkers.txt
$scriptPath = Split-Path -Parent $MyInvocation.ScriptName
$medewerkersFile = Join-Path $scriptPath "apps\medewerkers.txt"
if (-not (Test-Path $medewerkersFile)) {
Write-ColorText "Medewerkers.txt bestand niet gevonden!" "Red"
Wait-ForUser
return
}
# Lees de apps uit het bestand
$content = Get-Content $medewerkersFile -Raw
$apps = @()
# Parse de PowerShell array uit het bestand
if ($content -match '\$apps\s*=\s*@\s*\((.*?)\)') {
$appsString = $matches[1]
$apps = $appsString -split ',' | ForEach-Object { $_.Trim() -replace '"', '' } | Where-Object { $_ -ne '' }
}
if ($apps.Count -eq 0) {
Write-ColorText "Geen apps gevonden in medewerkers.txt!" "Red"
Wait-ForUser
return
}
Write-ColorText "Gevonden $($apps.Count) apps voor medewerkers:" "Cyan"
foreach ($app in $apps) {
Write-ColorText " - $app" "White"
}
Write-Host ""
$totalApps = $apps.Count
$currentApp = 0
foreach ($app in $apps) {
$currentApp++
Write-ColorText "[$currentApp/$totalApps] Installeer $app..." "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-ColorText "✓ $app succesvol geïnstalleerd" "Green"
} catch {
Write-ColorText "✗ Fout bij installatie van $app" "Red"
Write-ColorText "Foutdetails: $($_.Exception.Message)" "Red"
}
Write-Host ""
}
Write-ColorText "Medewerkers app installatie voltooid!" "Green"
Wait-ForUser
}
# Functie voor gasten apps
function Install-GastenApps {
Write-ColorText "=== INSTALL GASTEN APPS ===" "Green"
Write-Host ""
# Lees apps uit gasten.txt
$scriptPath = Split-Path -Parent $MyInvocation.ScriptName
$gastenFile = Join-Path $scriptPath "apps\gasten.txt"
if (-not (Test-Path $gastenFile)) {
Write-ColorText "Gasten.txt bestand niet gevonden!" "Red"
Wait-ForUser
return
}
# Lees de apps uit het bestand
$content = Get-Content $gastenFile -Raw
$apps = @()
# Parse de PowerShell array uit het bestand
if ($content -match '\$apps\s*=\s*@\s*\((.*?)\)') {
$appsString = $matches[1]
$apps = $appsString -split ',' | ForEach-Object { $_.Trim() -replace '"', '' } | Where-Object { $_ -ne '' }
}
if ($apps.Count -eq 0) {
Write-ColorText "Geen apps gevonden in gasten.txt!" "Red"
Wait-ForUser
return
}
Write-ColorText "Gevonden $($apps.Count) apps voor gasten:" "Cyan"
foreach ($app in $apps) {
Write-ColorText " - $app" "White"
}
Write-Host ""
$totalApps = $apps.Count
$currentApp = 0
foreach ($app in $apps) {
$currentApp++
Write-ColorText "[$currentApp/$totalApps] Installeer $app..." "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-ColorText "✓ $app succesvol geïnstalleerd" "Green"
} catch {
Write-ColorText "✗ Fout bij installatie van $app" "Red"
Write-ColorText "Foutdetails: $($_.Exception.Message)" "Red"
}
Write-Host ""
}
Write-ColorText "Gasten app installatie voltooid!" "Green"
Wait-ForUser
}
# =============================================================================
# OPTIE 4: UPDATE APPS
# =============================================================================
function Update-Apps {
Write-ColorText "=== UPDATE APPS ===" "Green"
Write-Host ""
# Controleer administrator rechten
if (-not (Test-AdministratorRights)) {
Write-ColorText "Administrator rechten zijn vereist. Start het script opnieuw als administrator." "Red"
Wait-ForUser
return
}
# Controleer winget
if (-not (Test-WingetAvailable)) {
Write-ColorText "Winget is niet geïnstalleerd. Installeer eerst de App Installer vanuit de Microsoft Store." "Red"
Wait-ForUser
return
}
Write-ColorText "Starting application updates..." "Yellow"
Write-Host ""
try {
# Voer winget upgrade uit voor alle applicaties
Write-ColorText "Update alle applicaties via winget..." "Cyan"
winget upgrade --all --silent --accept-source-agreements --accept-package-agreements --include-unknown
Write-Host ""
Write-ColorText "Update proces is voltooid." "Green"
} catch {
Write-ColorText "Fout bij het updaten van applicaties: $($_.Exception.Message)" "Red"
}
Wait-ForUser
}
# =============================================================================
# OPTIE 5: UPDATE ALL
# =============================================================================
function Update-All {
Write-ColorText "=== UPDATE ALL (COMPLETE SYSTEEM UPDATE) ===" "Green"
Write-Host ""
# Controleer administrator rechten
if (-not (Test-AdministratorRights)) {
Write-ColorText "Dit script moet als Administrator worden uitgevoerd!" "Red"
Write-ColorText "Start PowerShell opnieuw als Administrator en voer dit script opnieuw uit." "Yellow"
Wait-ForUser
return
}
Write-ColorText "Dit zal een complete systeem update uitvoeren inclusief:" "Yellow"
Write-ColorText "- Windows Updates" "White"
Write-ColorText "- Driver Updates" "White"
Write-ColorText "- Applicatie Updates" "White"
Write-ColorText "- Systeem Optimalisatie" "White"
Write-Host ""
$confirm = Read-Host "Weet je zeker dat je wilt doorgaan? (j/n)"
if ($confirm -ne "j" -and $confirm -ne "J" -and $confirm -ne "y" -and $confirm -ne "Y") {
Write-ColorText "Update geannuleerd." "Yellow"
Wait-ForUser
return
}
# Voer het complete update script uit
$scriptPath = Split-Path -Parent $MyInvocation.ScriptName
$updateAllScript = Join-Path $scriptPath "scripts\update-all.cmd"
if (Test-Path $updateAllScript) {
Write-ColorText "Start complete systeem update..." "Green"
Write-Host ""
try {
# Voer het update-all script uit
& $updateAllScript
} catch {
Write-ColorText "Fout bij het uitvoeren van het update script: $($_.Exception.Message)" "Red"
}
} else {
Write-ColorText "Update-all.cmd script niet gevonden!" "Red"
Write-ColorText "Zorg ervoor dat het script zich bevindt in: $updateAllScript" "Yellow"
}
Wait-ForUser
}
# =============================================================================
# HOOFDMENU LOOP
# =============================================================================
# Hoofdmenu loop
do {
Show-MenuHeader
Show-MainMenu
$choice = Read-Host "Maak uw keuze (0-5)"
switch ($choice) {
"1" {
Get-SerialNumber
}
"2" {
Set-Background
}
"3" {
Install-Apps
}
"4" {
Update-Apps
}
"5" {
Update-All
}
"0" {
Write-ColorText "Bedankt voor het gebruik van het HHO Configuratie Menu!" "Green"
Write-Host ""
Write-ColorText "Het script wordt afgesloten..." "Yellow"
Start-Sleep -Seconds 2
break
}
default {
Write-ColorText "Ongeldige keuze. Probeer opnieuw." "Red"
Start-Sleep -Seconds 2
}
}
} while ($choice -ne "0")
Write-ColorText "Script beëindigd." "Cyan"
+4 -4
View File
@@ -3,10 +3,10 @@ setlocal enabledelayedexpansion
echo Retrieving laptop serial number...
:: Gebruik de huidige map als uitvoerlocatie
set "output_dir=%~dp0"
:: Verwijder de backslash aan het einde
set "output_dir=!output_dir:~0,-1!"
:: 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
+72 -10
View File
@@ -52,16 +52,78 @@ Write-Host "Alle dependencies zijn beschikbaar. Start met app installaties..." -
Write-Host ""
# Install apps
$apps = @(
"Microsoft.DotNet.DesktopRuntime.8",
"Google.Chrome",
"Google.GoogleDrive",
"Google.ChromeRemoteDesktopHost",
"Dell.CommandUpdate",
"Logitech.OptionsPlus",
"Notepad++.Notepad++",
"Adobe.Acrobat.Reader.64-bit"
)
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
File renamed without changes.
+3 -51
View File
@@ -382,59 +382,12 @@ try {
}
# =============================================================================
# STAP 5: OPTIONELE APPLICATIE INSTALLATIES
# STAP 5: SYSTEEM OPTIMALISATIE
# =============================================================================
Write-Host ""
Write-Host "STAP 5: Optionele Applicatie Installaties..." -ForegroundColor Green
Show-Progress -Activity "Applicatie Installaties" -Status "Installeer essentiële applicaties..." -PercentComplete 80
# Lijst van essentiële applicaties
$essentialApps = @(
"Microsoft.DotNet.DesktopRuntime.8",
"Google.Chrome",
"Google.GoogleDrive",
"Google.ChromeRemoteDesktopHost",
"Dell.CommandUpdate",
"Logitech.OptionsPlus",
"Notepad++.Notepad++"
)
$totalApps = $essentialApps.Count
$currentApp = 0
foreach ($app in $essentialApps) {
$currentApp++
$percentComplete = 80 + (($currentApp / $totalApps) * 15)
Show-Progress -Activity "Applicatie Installaties" -Status "Installeer $app..." -PercentComplete $percentComplete
Write-Host "[$currentApp/$totalApps] Controleer $app..." -ForegroundColor Cyan
try {
# Controleer of app al geïnstalleerd is
$installed = winget list --id $app --exact 2>$null
if (-not $installed -or $installed -match "No installed package found") {
Write-Host "Installeer $app..." -ForegroundColor Yellow
winget install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine 2>$null
Write-Host "✓ $app succesvol geïnstalleerd" -ForegroundColor Green
Write-Log "Applicatie geïnstalleerd: $app" "INFO"
} else {
Write-Host "✓ $app is al geïnstalleerd" -ForegroundColor Green
}
} catch {
Write-Host "✗ Fout bij installatie van $app" -ForegroundColor Red
Write-Log "Fout bij installatie van $app" "ERROR"
}
}
# =============================================================================
# STAP 6: SYSTEEM OPTIMALISATIE
# =============================================================================
Write-Host ""
Write-Host "STAP 6: Systeem Optimalisatie..." -ForegroundColor Green
Show-Progress -Activity "Systeem Optimalisatie" -Status "Voer systeem optimalisatie uit..." -PercentComplete 95
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
@@ -482,7 +435,6 @@ 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 "✓ Essentiële applicaties geïnstalleerd" -ForegroundColor Green
Write-Host "✓ Systeem optimalisatie uitgevoerd" -ForegroundColor Green
Write-Host ""
File renamed without changes.