Alex
Alex

Reputation: 177

Set-ADAccountPassword specifying -Credential

I triyng to reset a password using this code:

Set-ADAccountPassword -Identity <username> -Reset -NewPassword (ConvertTo-SecureString -AsPlainText 'N3WP@SS' -Force)

But it uses the credentials of the logged user to execute this action. How do I specify other user to perform this action using -Credential?

Upvotes: 0

Views: 520

Answers (1)

Monika Reddy
Monika Reddy

Reputation: 963

If you are trying to specify other user :

PSCredential Specifies the user account credentials to use to perform this task. The default credentials are the credentials of the currently logged on user unless the cmdlet is run from an Active Directory module for Windows PowerShell provider drive. If the cmdlet is run from such a provider drive, the account associated with the drive is the default.

To specify this parameter, you can type a user name, such as User1 or Domain01\User01 or you can specify a PSCredential object. If you specify a user name for this parameter, the cmdlet prompts for a password.

You can also create a PSCredential object by using a script or by using the Get-Credential cmdlet. You can then set the Credential parameter to the PSCredential object.

  1. Prompt a specified user to change their password.

Use this command below :

Set-ADAccountPassword -Identity TestName

Please enter the current password for 'CN=Evan Narvaez,CN=Users,DC=Fabrikam,DC=com'
Password:********** 
Please enter the desired password for 'CN=Evan Narvaez,CN=Users,DC=Fabrikam,DC=com'
Password:*********** 
Repeat Password:***********
  1. Set a password for a user account using a distinguished name :

Set-ADAccountPassword -Identity 'CN=Elisa Daugherty,OU=Accounts,DC=Fabrikam,DC=com' -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force)

Please take a look at this doc for more reference : Ser-ADAccountPassword

Upvotes: 1

Related Questions