2024-03-23 14:38:06 +00:00
|
|
|
#!/bin/pwsh
|
2024-08-07 19:05:32 +00:00
|
|
|
. "$PSScriptRoot/../../../Common/Scripts/Context.ps1";
|
2024-03-23 14:38:06 +00:00
|
|
|
. "$PSScriptRoot/Add.ps1";
|
|
|
|
|
|
|
|
function Install-PersonalUsers([Context] $context) {
|
|
|
|
$null = New-Module {
|
2024-03-24 00:59:39 +00:00
|
|
|
$userIDProperty = "User";
|
|
|
|
|
2024-03-23 22:26:22 +00:00
|
|
|
function Get-UserID {
|
2024-03-23 14:38:06 +00:00
|
|
|
return $context.Get($userIDProperty);
|
|
|
|
}
|
2024-03-23 22:26:22 +00:00
|
|
|
function Set-UserID {
|
2024-03-23 14:38:06 +00:00
|
|
|
param([int]$value);
|
|
|
|
$context.Set($userIDProperty, $value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$userID = Get-UserID;
|
|
|
|
|
|
|
|
if ($null -eq $userID) {
|
|
|
|
Set-UserID ($context.UserNames.Count - 1);
|
|
|
|
$userID = Get-UserID;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($userID -ge 0) {
|
|
|
|
New-PersonalUser $context $($context.UserNames[$userID]);
|
|
|
|
Set-UserID ($userID - 1);
|
2024-03-23 14:57:25 +00:00
|
|
|
} else {
|
|
|
|
Get-LocalUser | Where-Object { $_.Name -in $context.UserNames } |
|
|
|
|
Enable-LocalUser;
|
2024-03-23 14:38:06 +00:00
|
|
|
}
|
|
|
|
}
|