Share via

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

3 answers

Sort by: Most helpful
  1. Rich Matheisen 48,036 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.

  3. Vietnam Hernández Castillo 0 Reputation points
    2026-02-20T09:25:30.0066667+00:00

    Hi,Pradeep

    I had the same problem and I solved it, the account was bloked by LAPS GPO.

    Have you checked that the account isn't managed by a GPO or Security Policy?

    Bye


Your answer

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