Below is an example of a code that allows you to change password of the Built-in Local Windows Administrator, as well as configure some account settings:
$LocalUsers = Get-LocalUser
Foreach ($LocalUser in $LocalUsers) {
If ($LocalUser.SID.Value -match ".*-500") {
$Admin = $LocalUser}}
$MyPass = Get-Credential -Credential $Admin.Name
Enable-LocalUser $Admin
Set-LocalUser $Admin -PasswordNeverExpires $true -Password $MyPass.Password
You must run the script with elevated privileges.
Foreach ($LocalUser in $LocalUsers) {
If ($LocalUser.SID.Value -match ".*-500") {
$Admin = $LocalUser}}
$MyPass = Get-Credential -Credential $Admin.Name
Enable-LocalUser $Admin
Set-LocalUser $Admin -PasswordNeverExpires $true -Password $MyPass.Password
You must run the script with elevated privileges.
No comments:
Post a Comment