-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoke-Bootstrap.ps1
More file actions
45 lines (39 loc) · 1.24 KB
/
Invoke-Bootstrap.ps1
File metadata and controls
45 lines (39 loc) · 1.24 KB
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
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[string]$ModulePath,
[ValidateSet('SilentlyContinue', 'Continue', 'Inquire', 'Break', 'Stop', IgnoreCase = $true)]
[Parameter(Mandatory = $false)]
[string]$ProgressPreference = 'SilentlyContinue'
)
# Set $ProgressPreference
$global:ProgressPreference = $ProgressPreference
if (-not $ModulePath) {
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$ModuleDir = Split-Path -Path $ScriptDir -Parent
$ModulePath = Join-Path -Path $ModuleDir -ChildPath 'WinGetBootstrap.psm1'
}
if (-not (Test-Path -Path $ModulePath -PathType Leaf)) {
Write-Error "Module file not found: $ModulePath"
exit 1
}
try {
Write-Verbose "Importing module from $ModulePath"
Import-Module -Name $ModulePath -Force -ErrorAction Stop
} catch {
Write-Error "Failed to import module: $_"
exit 1
}
# Check if -Verbose is set
if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey('Verbose')) {
$Expression = "Install-WinGetModule -Verbose"
} else {
$Expression = "Install-WinGetModule"
}
try {
Write-Verbose "Installing WinGet module"
Invoke-Expression $Expression -ErrorAction Stop
} catch {
Write-Error "Failed to install WinGet module: $_"
exit 1
}