Rename user using PowerShell function call

This commit is contained in:
Manuel Thalmann 2023-06-27 00:57:24 +02:00
parent cdf07a5d54
commit 1f82f78c7f

View file

@ -29,7 +29,7 @@ function New-PersonalUser([Context] $context)
}
Write-Information "Renaming the new User to $($context.UserName)";
wmic useraccount where "name='$user'" rename "$context.UserName";
Rename-LocalUser $user $context.UserName;
Add-LocalGroupMember -Group "Administrators" -Member $user && Set-LocalUser $context.AdminName -Password (ConvertTo-SecureString -AsPlainText "Admin");
Write-Host "Registering setup script for all new users";