Configure MS accounts properly
This commit is contained in:
parent
6ba58ee07e
commit
4f2781b154
1 changed files with 16 additions and 1 deletions
|
@ -502,8 +502,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;
|
||||
|
||||
|
@ -523,12 +527,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue