Files

795 lines
30 KiB
PowerShell

# 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 "6. Enable BitLocker Encryption" "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 = if ($MyInvocation.MyCommand.Path) {
Split-Path -Parent $MyInvocation.MyCommand.Path
} elseif ($MyInvocation.ScriptName) {
Split-Path -Parent $MyInvocation.ScriptName
} elseif ($PSCommandPath) {
Split-Path -Parent $PSCommandPath
} elseif ($PSScriptRoot) {
$PSScriptRoot
} else {
# When executed via .cmd wrapper, PUSHD sets current directory
$location = Get-Location
if ($location -is [System.IO.DirectoryInfo]) {
$location.FullName
} else {
$location.ToString()
}
}
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 = if ($MyInvocation.MyCommand.Path) {
Split-Path -Parent $MyInvocation.MyCommand.Path
} elseif ($MyInvocation.ScriptName) {
Split-Path -Parent $MyInvocation.ScriptName
} elseif ($PSCommandPath) {
Split-Path -Parent $PSCommandPath
} elseif ($PSScriptRoot) {
$PSScriptRoot
} else {
# When executed via .cmd wrapper, PUSHD sets current directory
$location = Get-Location
if ($location -is [System.IO.DirectoryInfo]) {
$location.FullName
} else {
$location.ToString()
}
}
$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 (multiline pattern)
if ($content -match '(?s)\$apps\s*=\s*@\s*\((.*?)\)') {
$appsString = $matches[1]
# Split on comma or newline, then clean up each item
$apps = @()
$lines = $appsString -split '[,\r\n]+'
foreach ($line in $lines) {
$item = $line.Trim()
# Skip empty lines
if ([string]::IsNullOrWhiteSpace($item)) { continue }
# Remove quotes from both ends (handle both single and double quotes)
$item = $item -replace '^["'']+', '' -replace '["'']+$', ''
# Remove any remaining whitespace and newlines
$item = $item.Trim().Replace("`r", '').Replace("`n", '')
# Only add if not empty
if ($item -and $item -ne '') {
$apps += $item
}
}
}
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 {
# Capture output using Invoke-Expression to properly capture stdout
$output = & winget install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine 2>&1
$exitCode = $LASTEXITCODE
$outputString = $output | Out-String
# Determine result based on output content and exit code
if ($exitCode -eq 0 -or $outputString -match "Successfully installed|Successfully verified") {
$msg = "OK $app succesvol geinstalleerd"
Write-ColorText $msg "Green"
} elseif ($outputString -match "already installed|existing package|No applicable upgrade|No available upgrade|Found an existing package|Trying to upgrade") {
$msg = "OK $app is al geinstalleerd (geen actie nodig)"
Write-ColorText $msg "Yellow"
} elseif ($outputString -match "No upgrade available|No newer package versions") {
$msg = "OK $app is al geinstalleerd (geen actie nodig)"
Write-ColorText $msg "Yellow"
} elseif ($outputString -match "No package found|No applicable packages found") {
$msg = "FOUT: Package niet gevonden: $app (Controleer de package ID)"
Write-ColorText $msg "Red"
} else {
# Show error with exit code for debugging
$msg = "FOUT bij installatie van $app (Exit code: $exitCode)"
Write-ColorText $msg "Red"
if ($outputString) {
$shortOutput = $outputString.Substring(0, [Math]::Min(200, $outputString.Length))
$outputMsg = " Output: $shortOutput..."
Write-ColorText $outputMsg "Gray"
}
}
} catch {
Write-ColorText "✗ Fout bij installatie van $app" "Red"
if ($_.Exception.Message) {
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 = if ($MyInvocation.MyCommand.Path) {
Split-Path -Parent $MyInvocation.MyCommand.Path
} elseif ($MyInvocation.ScriptName) {
Split-Path -Parent $MyInvocation.ScriptName
} elseif ($PSCommandPath) {
Split-Path -Parent $PSCommandPath
} elseif ($PSScriptRoot) {
$PSScriptRoot
} else {
# When executed via .cmd wrapper, PUSHD sets current directory
$location = Get-Location
if ($location -is [System.IO.DirectoryInfo]) {
$location.FullName
} else {
$location.ToString()
}
}
$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 (multiline pattern)
if ($content -match '(?s)\$apps\s*=\s*@\s*\((.*?)\)') {
$appsString = $matches[1]
# Split on comma or newline, then clean up each item
$apps = @()
$lines = $appsString -split '[,\r\n]+'
foreach ($line in $lines) {
$item = $line.Trim()
# Skip empty lines
if ([string]::IsNullOrWhiteSpace($item)) { continue }
# Remove quotes from both ends (handle both single and double quotes)
$item = $item -replace '^["'']+', '' -replace '["'']+$', ''
# Remove any remaining whitespace and newlines
$item = $item.Trim().Replace("`r", '').Replace("`n", '')
# Only add if not empty
if ($item -and $item -ne '') {
$apps += $item
}
}
}
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 {
# Capture output using Invoke-Expression to properly capture stdout
$output = & winget install --id $app -e --silent --accept-package-agreements --accept-source-agreements --source winget --scope machine 2>&1
$exitCode = $LASTEXITCODE
$outputString = $output | Out-String
# Determine result based on output content and exit code
if ($exitCode -eq 0 -or $outputString -match "Successfully installed|Successfully verified") {
$msg = "OK $app succesvol geinstalleerd"
Write-ColorText $msg "Green"
} elseif ($outputString -match "already installed|existing package|No applicable upgrade|No available upgrade|Found an existing package|Trying to upgrade") {
$msg = "OK $app is al geinstalleerd (geen actie nodig)"
Write-ColorText $msg "Yellow"
} elseif ($outputString -match "No upgrade available|No newer package versions") {
$msg = "OK $app is al geinstalleerd (geen actie nodig)"
Write-ColorText $msg "Yellow"
} elseif ($outputString -match "No package found|No applicable packages found") {
$msg = "FOUT: Package niet gevonden: $app (Controleer de package ID)"
Write-ColorText $msg "Red"
} else {
# Show error with exit code for debugging
$msg = "FOUT bij installatie van $app (Exit code: $exitCode)"
Write-ColorText $msg "Red"
if ($outputString) {
$shortOutput = $outputString.Substring(0, [Math]::Min(200, $outputString.Length))
$outputMsg = " Output: $shortOutput..."
Write-ColorText $outputMsg "Gray"
}
}
} catch {
Write-ColorText "✗ Fout bij installatie van $app" "Red"
if ($_.Exception.Message) {
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 = if ($MyInvocation.MyCommand.Path) {
Split-Path -Parent $MyInvocation.MyCommand.Path
} elseif ($MyInvocation.ScriptName) {
Split-Path -Parent $MyInvocation.ScriptName
} elseif ($PSCommandPath) {
Split-Path -Parent $PSCommandPath
} elseif ($PSScriptRoot) {
$PSScriptRoot
} else {
# When executed via .cmd wrapper, PUSHD sets current directory
$location = Get-Location
if ($location -is [System.IO.DirectoryInfo]) {
$location.FullName
} else {
$location.ToString()
}
}
$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
}
# =============================================================================
# OPTIE 6: ENABLE BITLOCKER
# =============================================================================
function Enable-BitLocker {
Write-ColorText "=== ENABLE BITLOCKER ENCRYPTION ===" "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
}
# Controleer of BitLocker beschikbaar is
try {
$bitlockerModule = Get-Module -ListAvailable -Name "BitLocker"
if (-not $bitlockerModule) {
Write-ColorText "BitLocker is niet beschikbaar op dit systeem!" "Red"
Write-ColorText "BitLocker is alleen beschikbaar op Windows Pro, Enterprise of Education edities." "Yellow"
Wait-ForUser
return
}
} catch {
Write-ColorText "Fout bij het controleren van BitLocker beschikbaarheid: $($_.Exception.Message)" "Red"
Wait-ForUser
return
}
Write-ColorText "BitLocker is beschikbaar op dit systeem." "Green"
Write-Host ""
# Controleer huidige BitLocker status
try {
Import-Module BitLocker -ErrorAction Stop
$bitlockerVolume = Get-BitLockerVolume -MountPoint "C:" -ErrorAction Stop
$currentStatus = $bitlockerVolume.VolumeStatus
Write-ColorText "Huidige BitLocker status: $currentStatus" "Yellow"
if ($currentStatus -eq "FullyEncrypted") {
Write-ColorText "BitLocker is al volledig ingeschakeld op dit systeem." "Green"
# Probeer bestaande recovery key op te halen
$recoveryKeyProtector = $bitlockerVolume.KeyProtector | Where-Object { $_.KeyProtectorType -eq "RecoveryPassword" }
if ($recoveryKeyProtector) {
Write-ColorText "Bestaande recovery key wordt opgeslagen..." "Yellow"
# Zorg dat output map bestaat
$scriptPath = if ($MyInvocation.MyCommand.Path) {
Split-Path -Parent $MyInvocation.MyCommand.Path
} elseif ($MyInvocation.ScriptName) {
Split-Path -Parent $MyInvocation.ScriptName
} elseif ($PSCommandPath) {
Split-Path -Parent $PSCommandPath
} elseif ($PSScriptRoot) {
$PSScriptRoot
} else {
# When executed via .cmd wrapper, PUSHD sets current directory
$location = Get-Location
if ($location -is [System.IO.DirectoryInfo]) {
$location.FullName
} else {
$location.ToString()
}
}
$outputPath = Join-Path $scriptPath "output"
if (-not (Test-Path $outputPath)) {
New-Item -ItemType Directory -Path $outputPath -Force | Out-Null
}
$recoveryKeyFile = Join-Path $outputPath "bitlocker_$env:COMPUTERNAME.txt"
$recoveryInfo = @"
Bestaande BitLocker Recovery Key
===============================
Datum: $(Get-Date -Format "yyyy-MM-dd HH:mm:ss")
Computer: $env:COMPUTERNAME
Schijf: C:
Recovery Key: $($recoveryKeyProtector.RecoveryPassword)
BELANGRIJK:
- Deze recovery key was al gegenereerd tijdens de eerste BitLocker setup
- Bewaar deze recovery key op een veilige plaats
- Zonder deze key kunt u uw gegevens niet herstellen
"@
$recoveryInfo | Out-File -FilePath $recoveryKeyFile -Encoding UTF8
Write-ColorText "Bestaande recovery key opgeslagen in: $recoveryKeyFile" "Green"
}
} else {
Write-ColorText "WAARSCHUWING: Dit proces kan lang duren en vereist een systeemherstel!" "Red"
Write-ColorText "- Het systeem moet opnieuw worden opgestart tijdens het proces" "Yellow"
Write-ColorText "- Zorg ervoor dat alle belangrijke gegevens zijn opgeslagen" "Yellow"
Write-ColorText "- Het proces kan enkele uren duren afhankelijk van de schijfgrootte" "Yellow"
Write-Host ""
$confirm = Read-Host "Wilt u doorgaan met BitLocker versleuteling? (ja/nee)"
if ($confirm -ne "ja" -and $confirm -ne "j" -and $confirm -ne "yes" -and $confirm -ne "y") {
Write-ColorText "BitLocker versleuteling geannuleerd." "Yellow"
Wait-ForUser
return
}
# Voer het BitLocker script uit
$scriptPath = if ($MyInvocation.MyCommand.Path) {
Split-Path -Parent $MyInvocation.MyCommand.Path
} elseif ($MyInvocation.ScriptName) {
Split-Path -Parent $MyInvocation.ScriptName
} elseif ($PSCommandPath) {
Split-Path -Parent $PSCommandPath
} elseif ($PSScriptRoot) {
$PSScriptRoot
} else {
# When executed via .cmd wrapper, PUSHD sets current directory
$location = Get-Location
if ($location -is [System.IO.DirectoryInfo]) {
$location.FullName
} else {
$location.ToString()
}
}
$bitlockerScript = Join-Path $scriptPath "scripts\enable-bitlocker.ps1"
if (Test-Path $bitlockerScript) {
Write-ColorText "Start BitLocker versleuteling..." "Green"
Write-Host ""
try {
# Voer het BitLocker script uit
& $bitlockerScript
} catch {
Write-ColorText "Fout bij het uitvoeren van het BitLocker script: $($_.Exception.Message)" "Red"
}
} else {
Write-ColorText "enable-bitlocker.ps1 script niet gevonden!" "Red"
Write-ColorText "Zorg ervoor dat het script zich bevindt in: $bitlockerScript" "Yellow"
}
}
} catch {
Write-ColorText "Fout bij het controleren van BitLocker status: $($_.Exception.Message)" "Red"
}
Wait-ForUser
}
# =============================================================================
# HOOFDMENU LOOP
# =============================================================================
# Hoofdmenu loop
do {
Show-MenuHeader
Show-MainMenu
$choice = Read-Host "Maak uw keuze (0-6)"
switch ($choice) {
"1" {
Get-SerialNumber
}
"2" {
Set-Background
}
"3" {
Install-Apps
}
"4" {
Update-Apps
}
"5" {
Update-All
}
"6" {
Enable-BitLocker
}
"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"