Store stages using their name

This commit is contained in:
Manuel Thalmann 2024-07-31 16:52:49 +02:00
parent 97ec1648fc
commit 42e818493c

View file

@ -3,8 +3,8 @@ using namespace System.Security.AccessControl;
using namespace System.Security.Principal; using namespace System.Security.Principal;
enum SetupStage { enum SetupStage {
Initialize = "init" Initialize
Install = "install" Install
} }
$null = New-Module { $null = New-Module {
@ -88,7 +88,7 @@ $null = New-Module {
Gets the name of the current setup stage. Gets the name of the current setup stage.
#> #>
function Get-Stage { function Get-Stage {
return Get-SetupOption $stageOption; return [SetupStage](Get-SetupOption $stageOption);
} }
<# <#
@ -100,9 +100,13 @@ $null = New-Module {
#> #>
function Set-Stage { function Set-Stage {
param( param(
[string] $Name $Name
) )
if (-not ($Name -is [string])) {
$Name = ([SetupStage]$Name).ToString();
}
$null = Set-SetupOption $stageOption $Name; $null = Set-SetupOption $stageOption $Name;
} }
@ -123,4 +127,13 @@ $null = New-Module {
$Value $Value
) )
} }
<#
.SYNOPSIS
Checks whether the active session is executed with admin rights.
#>
function Test-Admin {
net session 2> $null | Out-Null;
return $?;
}
} }