From 9a3c5f6b3207fbab695850a54ab7375b30f400cc Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 31 Jul 2024 16:52:49 +0200 Subject: [PATCH] Store stages using their name --- scripts/Windows/Scripts/SetupConfig.ps1 | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/Windows/Scripts/SetupConfig.ps1 b/scripts/Windows/Scripts/SetupConfig.ps1 index 4b0cf50f..5382304b 100644 --- a/scripts/Windows/Scripts/SetupConfig.ps1 +++ b/scripts/Windows/Scripts/SetupConfig.ps1 @@ -3,8 +3,8 @@ using namespace System.Security.AccessControl; using namespace System.Security.Principal; enum SetupStage { - Initialize = "init" - Install = "install" + Initialize + Install } $null = New-Module { @@ -88,7 +88,7 @@ $null = New-Module { Gets the name of the current setup stage. #> function Get-Stage { - return Get-SetupOption $stageOption; + return [SetupStage](Get-SetupOption $stageOption); } <# @@ -100,9 +100,13 @@ $null = New-Module { #> function Set-Stage { param( - [string] $Name + $Name ) + if (-not ($Name -is [string])) { + $Name = ([SetupStage]$Name).ToString(); + } + $null = Set-SetupOption $stageOption $Name; } @@ -123,4 +127,13 @@ $null = New-Module { $Value ) } + + <# + .SYNOPSIS + Checks whether the active session is executed with admin rights. + #> + function Test-Admin { + net session 2> $null | Out-Null; + return $?; + } }