From 152b5b2dd881b720949bd2ecd81dd891d8d33e9a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 10 Aug 2024 15:21:13 +0200 Subject: [PATCH] Configure MS accounts properly --- scripts/Windows/OS/Install.ps1 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index cc7145d2..b875382d 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -499,8 +499,12 @@ $null = New-Module { $user = Get-LocalUser $users[$currentUser]; $msAccount = Get-UserConfig -UserName "$user" -Name "microsoftAccount"; + $adminGroup = @{ + SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null); + }; + Add-LocalGroupMember ` - -SID ([SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null))` + @adminGroup ` $user ` -ErrorAction SilentlyContinue; @@ -520,12 +524,23 @@ $null = New-Module { Restart-Intermediate -DefaultUser; return; } else { + $configure = { + Deploy-SoftwareAction -Action ([InstallerAction]::ConfigureUser); + Remove-LocalGroupMember -Member "$user" @adminGroup -ErrorAction SilentlyContinue; + } + if ($msAccount) { if (-not (Test-Admin)) { Invoke-OneShot DisableUAC; Restart-Computer; return; + } else { + & $configure; + Clear-SetupRegistration; + Disable-OneShotListener; } + } else { + & $configure; } }