30 lines
673 B
PowerShell
30 lines
673 B
PowerShell
|
#!/bin/pwsh
|
||
|
. "$PSScriptRoot/../../Scripts/Context.ps1";
|
||
|
. "$PSScriptRoot/Add.ps1";
|
||
|
|
||
|
function Install-PersonalUsers([Context] $context) {
|
||
|
$userIDProperty = "User";
|
||
|
|
||
|
$null = New-Module {
|
||
|
Get-UserID {
|
||
|
return $context.Get($userIDProperty);
|
||
|
}
|
||
|
Set-UserID {
|
||
|
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);
|
||
|
}
|
||
|
}
|