31 lines
1,015 B
PowerShell
31 lines
1,015 B
PowerShell
. "$PSScriptRoot/../Scripts/Context.ps1";
|
|
|
|
function New-PersonalUser([Context] $context)
|
|
{
|
|
Write-Host "Creating Personal User";
|
|
|
|
if (-not (Get-LocalUser $context.UserName))
|
|
{
|
|
while ($true) {
|
|
Write-Host (
|
|
[string]::Join(
|
|
"`n",
|
|
"So... Windows is too dumb to create users which are bound to a Microsoft Account.",
|
|
"Thus, you have to do it by yourself.",
|
|
"So sorry..."));
|
|
|
|
$users = Get-LocalUser | Select-Object { $_.Name };
|
|
Read-Host "Please hit enter once you're done...";
|
|
|
|
$user = Get-LocalUser | Select-Object { -not ($users -contains $_.Name) } | Select-Object -Last -1;
|
|
|
|
if ($user) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
Rename-LocalUser $user $context.UserName;
|
|
Add-LocalGroupMember -Group "Administrators" -Member $user && Set-LocalUser $context.AdminName -Password (ConvertTo-SecureString "Admin");
|
|
}
|
|
}
|