diff --git a/scripts/Windows/OS/User.ps1 b/scripts/Windows/OS/User.ps1 index 7f21e91f..ca799d5f 100644 --- a/scripts/Windows/OS/User.ps1 +++ b/scripts/Windows/OS/User.ps1 @@ -6,17 +6,24 @@ function New-PersonalUser([Context] $context) if (-not (Get-LocalUser $context.UserName)) { - 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...")); + 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; - $users = Get-LocalUser | Select-Object { $_.Name }; - Read-Host "Please hit enter once you're done..."; + if ($user) { + break; + } + } - $user = Get-LocalUser | Select-Object { -not ($users -contains $_.Name) } | Select-Object -Last; Rename-LocalUser $user $context.UserName; Add-LocalGroupMember -Group "Administrators" -Member $user && Set-LocalUser $context.AdminName -Password (ConvertTo-SecureString "Admin"); }