In this Post I want to share a short script with you, for changing the local Administrator name dynamically. This can be done after the setup of Windows for example with a Script in a Task Sequence of SCCM.
The great thing is, that LAPS (LAPS – Change local Administrator password regularly) is still working fine, because in the default LAPS is using the SID and not the name of the Administrator Account.
The script will create a random name with 8 letters, you can also set a custom number of letters if you need more or less.
You can just copy this code and name the file for example change_local_admin.ps1
SCRIPT
#Create Random Name$newlocalusername = -join ((65..90) + (97..122) | Get-Random -Count 8 | % {[char]$_})#Set Random Name as Administrator Account NameRename-LocalUser -Name Administrator -NewName $newlocalusername