Add functions for handling options for creating users
This commit is contained in:
parent
e9778289b8
commit
a9ae57e16f
|
@ -9,12 +9,20 @@ enum SetupStage {
|
|||
Configure
|
||||
Install
|
||||
CreateUser
|
||||
ConfigureUser
|
||||
}
|
||||
|
||||
enum UserStage {
|
||||
Create
|
||||
Configure
|
||||
Completed
|
||||
}
|
||||
|
||||
$null = New-Module {
|
||||
[string] $configRoot = "HKLM:\Software\PortValhalla";
|
||||
[string] $stageOption = "Stage";
|
||||
[string] $userOption = "SetupUser";
|
||||
[string] $userStageOption = "UserStage";
|
||||
[string] $accountOption = "MSAccount";
|
||||
[string] $finishedOption = "Finished";
|
||||
[RegistryKey] $key = $null;
|
||||
|
||||
|
@ -273,6 +281,85 @@ $null = New-Module {
|
|||
$null = Set-SetupOption $stageOption $Name;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the current user to set up.
|
||||
#>
|
||||
function Get-CurrentUser {
|
||||
return (Get-SetupOption $userOption) ?? 0;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the index of the current user to set up.
|
||||
|
||||
.PARAMETER Value
|
||||
The index of the user to set up.
|
||||
#>
|
||||
function Set-CurrentUser {
|
||||
param(
|
||||
[int] $Value
|
||||
)
|
||||
|
||||
Set-SetupOption $userOption $value;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the name of the current stage of the user setup.
|
||||
#>
|
||||
function Get-UserStage {
|
||||
$stage = Get-SetupOption $userStageOption;
|
||||
|
||||
if ($null -ne $stage) {
|
||||
$stage = [UserStage]$stage;
|
||||
}
|
||||
|
||||
return $stage;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the current stage of the user setup.
|
||||
|
||||
.PARAMETER Name
|
||||
The name of the stage to set.
|
||||
#>
|
||||
function Set-UserStage {
|
||||
param(
|
||||
$Name
|
||||
)
|
||||
|
||||
if (-not (($null -eq $Name) -or ($Name -is [string]))) {
|
||||
$Name = ([UserStage]$Name).ToString();
|
||||
}
|
||||
|
||||
$null = Set-SetupOption $userStageOption $Name;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the name of the microsoft account to create.
|
||||
#>
|
||||
function Get-MSAccountName {
|
||||
return Get-SetupOption $accountOption;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the name of the microsoft account to create.
|
||||
|
||||
.PARAMETER Name
|
||||
The name of the microsoft account to create.
|
||||
#>
|
||||
function Set-MSAccountName {
|
||||
param(
|
||||
[string] $Name
|
||||
)
|
||||
|
||||
Set-SetupOption $accountOption $Name;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a value indicating whether the setup has finished.
|
||||
|
|
Loading…
Reference in a new issue