Rename user using wmic

This commit is contained in:
Manuel Thalmann 2023-06-26 02:14:44 +02:00
parent 45be15723e
commit cdf07a5d54

View file

@ -29,7 +29,7 @@ function New-PersonalUser([Context] $context)
}
Write-Information "Renaming the new User to $($context.UserName)";
Rename-LocalUser $user $context.UserName;
wmic useraccount where "name='$user'" rename "$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";