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 $?; + } }