Configure MS accounts properly
This commit is contained in:
parent
6ba58ee07e
commit
4f2781b154
|
@ -502,8 +502,12 @@ $null = New-Module {
|
||||||
$user = Get-LocalUser $users[$currentUser];
|
$user = Get-LocalUser $users[$currentUser];
|
||||||
$msAccount = Get-UserConfig -UserName "$user" -Name "microsoftAccount";
|
$msAccount = Get-UserConfig -UserName "$user" -Name "microsoftAccount";
|
||||||
|
|
||||||
|
$adminGroup = @{
|
||||||
|
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
||||||
|
};
|
||||||
|
|
||||||
Add-LocalGroupMember `
|
Add-LocalGroupMember `
|
||||||
-SID ([SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null))`
|
@adminGroup `
|
||||||
$user `
|
$user `
|
||||||
-ErrorAction SilentlyContinue;
|
-ErrorAction SilentlyContinue;
|
||||||
|
|
||||||
|
@ -523,12 +527,23 @@ $null = New-Module {
|
||||||
Restart-Intermediate -DefaultUser;
|
Restart-Intermediate -DefaultUser;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
$configure = {
|
||||||
|
Deploy-SoftwareAction -Action ([InstallerAction]::ConfigureUser);
|
||||||
|
Remove-LocalGroupMember -Member "$user" @adminGroup -ErrorAction SilentlyContinue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($msAccount) {
|
if ($msAccount) {
|
||||||
if (-not (Test-Admin)) {
|
if (-not (Test-Admin)) {
|
||||||
Invoke-OneShot DisableUAC;
|
Invoke-OneShot DisableUAC;
|
||||||
Restart-Computer;
|
Restart-Computer;
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
& $configure;
|
||||||
|
Clear-SetupRegistration;
|
||||||
|
Disable-OneShotListener;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
& $configure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue