Set-LocalUser : An unspecified error occurred: status = 3221226252

Pradeep Mishra 46 Reputation points
2025-01-15T16:09:03.5766667+00:00

I am trying to change user password based on below script but getting the error "Set-LocalUser : An unspecified error occurred: status = 3221226252".

$pks=Get-Date

foreach($pk in $pks){

$date=$pk.Day

$month=$pk.Month

$year=$pk.Year

$var01='prad'

$z=$year,$month, $date,$var01

$pp=-join $z

$pword = $pp | ConvertTo-SecureString -AsPlainText -Force

Set-LocalUser -Name "Admin" -Password $pword

}

Windows for business | Windows Server | User experience | PowerShell
{count} vote

2 answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2025-01-15T16:44:18.4366667+00:00

    Are you trying to change the local admin account?

    Verify that account you're trying to modify:

    1. exists
    2. isn’t disabled
    3. isn’t locked

    And, lastly, that your account has local admin rights (and you run the code from an elevated PowerShell session -- i.e., start the session with "Run as administrator").

    2 people found this answer helpful.
    0 comments No comments

  2. Pradeep Mishra 46 Reputation points
    2025-01-15T16:49:13.96+00:00

    Hi Rich,

    Yes, I am trying to changing local account password and account is exists and it is not disabled or Lock.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.