-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
74 lines (62 loc) · 1.83 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#Requires -RunAsAdministrator
#Requires -Version 7
[CmdletBinding()]
param(
[ValidateSet('Minimal', 'Standard', 'Full')]
[string]$InstallationType = 'Standard',
[switch]$Force,
[switch]$NoBackup,
[switch]$Silent,
[string]$LogPath
)
# Initialize error handling
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
try {
Write-Host "Script root: $PSScriptRoot"
# Load required helpers first
$helpersDirPath = Join-Path $PSScriptRoot "helpers"
$essentialHelpers = @(
"Logging\Write-Log.ps1"
)
foreach ($helper in $essentialHelpers) {
$helperPath = Join-Path $helpersDirPath $helper
if (Test-Path $helperPath) {
Write-Host "Loading helper: $helperPath"
. $helperPath
}
else {
throw "Essential helper not found: $helperPath"
}
}
# Import module
$modulePath = Join-Path $PSScriptRoot "WindowsSetup.psd1"
if (-not (Test-Path $modulePath)) {
throw "Module manifest not found at: $modulePath"
}
Write-Host "Importing module from: $modulePath"
# Use -Force to ensure clean loading and -Global to ensure proper scope
Import-Module $modulePath -Force -Global -DisableNameChecking
# Start installation with parameters
$params = @{
InstallationType = $InstallationType
Force = $Force
NoBackup = $NoBackup
Silent = $Silent
}
if ($LogPath) {
$params['LogPath'] = $LogPath
}
if ($DebugPreference -eq 'Continue') {
$params['Debug'] = $true
}
$result = Start-Installation @params
if (-not $result) {
throw "Installation failed without specific error"
}
}
catch {
Write-Error "Installation failed: $_"
Write-Error $_.ScriptStackTrace
exit 1
}git a