diff --git a/profiles/DerGeret/Windows/Restore.ps1 b/profiles/DerGeret/Windows/Restore.ps1 index 580636d8..78273de8 100644 --- a/profiles/DerGeret/Windows/Restore.ps1 +++ b/profiles/DerGeret/Windows/Restore.ps1 @@ -5,4 +5,5 @@ Write-Host "Starting Restoration of Windows"; . "$PSScriptRoot/../../../scripts/Windows/OS/Install.ps1"; [Context]$context = [Context]::new(); $context.EntryPoint = "$($MyInvocation.MyCommand.Path)"; +$context.UserName = "Manuel"; Invoke-WindowsInstallation $context; \ No newline at end of file diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index 23353544..90d12728 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -1,5 +1,6 @@ . "$PSScriptRoot/Manage.ps1"; . "$PSScriptRoot/Upgrade.ps1"; +. "$PSScriptRoot/User.ps1"; . "$PSScriptRoot/../Scripts/Context.ps1"; function Invoke-WindowsInstallation([Context] $context) @@ -7,5 +8,6 @@ function Invoke-WindowsInstallation([Context] $context) Write-Host "Starting Installation and Restoration of Windows"; . "$PSScriptRoot/../Scripts/Prerequisites.ps1"; Invoke-Upgrade $context; + New-PersonalUser $context; Invoke-WindowsRestore $context; } diff --git a/scripts/Windows/OS/User.ps1 b/scripts/Windows/OS/User.ps1 new file mode 100644 index 00000000..1e40c05c --- /dev/null +++ b/scripts/Windows/OS/User.ps1 @@ -0,0 +1,23 @@ +. "$PSScriptRoot/../Scripts/Context.ps1"; + +function New-PersonalUser([Context] $context) +{ + Write-Host "Creating Personal User"; + + 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...")); + + $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; + Rename-LocalUser $user $context.UserName; + Add-LocalGroupMember -Group "Administrators" -Member $user; + } +} diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index 413d8595..65953fce 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -2,6 +2,7 @@ class Context { [string]$EntryPoint; [string]$RootDir; [string]$BackupName; + [string]$UserName; [string] BackupRoot() { if (-not $this.RootDir) {