PowerShell Logo Small

Set-ADAccountPassword



This is the built-in help made by Microsoft for the command 'Set-ADAccountPassword', in PowerShell version 3 - as retrieved from Windows version 'Microsoft Windows Server 2012 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Modifies the password of an Active Directory account.

SYNTAX


Set-ADAccountPassword [-Identity] <ADAccount> [-AuthType <ADAuthType>] [-Credential <PSCredential>] [-NewPassword <SecureString>]
[-OldPassword <SecureString>] [-Partition <String>] [-PassThru [<SwitchParameter>]] [-Reset [<SwitchParameter>]] [-Server <String>] [-Confirm
[<SwitchParameter>]] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-ADAccountPassword cmdlet sets the password for a user, computer or service account.


The Identity parameter specifies the Active Directory account to modify.


You can identify an account by its distinguished name (DN), GUID, security identifier (SID) or security accounts manager (SAM) account name.
You can also set the Identity parameter to an object variable such as $<localADAccountObject>, or you can pass an object through the pipeline
to the Identity parameter. For example, you can use the Search-ADAccount cmdlet to retrieve an account object and then pass the object through
the pipeline to the Set-ADAccountPassword cmdlet. Similarly, you can use Get-ADUser, Get-ADComputer or Get-ADServiceAccount, for standalone
MSAs, cmdlets to retrieve account objects that you can pass through the pipeline to this cmdlet.


Note: Group MSAs cannot set password since they are changed at predetermined intervals.


You must set the OldPassword and the NewPassword parameters to set the password unless you specify the Reset parameter. When you specify the
Reset parameter, the password is set to the NewPassword value that you provide and the OldPassword parameter is not required.


For AD LDS environments, the Partition parameter must be specified except in the following two conditions:


-The cmdlet is run from an Active Directory provider drive.


-A default naming context or partition is defined for the AD LDS environment. To specify a default naming context for an AD LDS environment,
set the msDS-defaultNamingContext property of the Active Directory directory service agent (DSA) object (nTDSDSA) for the AD LDS instance.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkID=219353
Get-ADComputer
Get-ADServiceAccount
Get-ADUser
Search-ADAccount

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>Set-ADAccountPassword 'CN=Jeremy Los,OU=Accounts,DC=Fabrikam,DC=com' -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd"
-Force)



Description

-----------

Sets the password of the user account with DistinguishedName: 'CN=Jeremy Los,OU=Accounts,DC=Fabrikam,DC=com' to 'p@ssw0rd'.




-------------------------- EXAMPLE 2 --------------------------

C:\PS>Set-ADAccountPassword -Identity tmakovec -OldPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -NewPassword
(ConvertTo-SecureString -AsPlainText "qwert@12345" -Force)



Description

-----------

Sets the password of the user account with SamAccountName: tmakovec to 'qwert@12345'.




-------------------------- EXAMPLE 3 --------------------------

C:\PS>Set-ADAccountPassword -Identity saradavi

Please enter the current password for 'CN=Sara Davis,CN=Users,DC=Fabrikam,DC=com'
Password:**********
Please enter the desired password for 'CN=Sara Davis,CN=Users,DC=Fabrikam,DC=com'
Password:***********
Repeat Password:***********



Description

-----------

Sets the password of the user account with DistinguishedName: 'CN=Sara Davis,CN=Users,DC=Fabrikam,DC=com' (user is prompted for old and new
password).




-------------------------- EXAMPLE 4 --------------------------

C:\PS>$newPassword = (Read-Host -Prompt "Provide New Password" -AsSecureString); Set-ADAccountPassword -Identity mollyd -NewPassword
$newPassword -Reset

Provide New Password: **********



Description

-----------

Prompts the user for a new password that is stored in a temporary variable named $newPassword, then uses it to reset the password for the user
account with SamAccountName: mollyd.




-------------------------- EXAMPLE 5 --------------------------

PS C:\Users\administrator.FABRIKAM> set-adaccountpassword "CN=Molly Dempsey,OU=AccountDeptOU,DC=AppNC" -server "dsp13a24:60000"


Please enter the current password for 'CN=mollyd,OU=AccountDeptOU,DC=AppNC'
Password:**********
Please enter the desired password for 'CN=mollyd,OU=AccountDeptOU,DC=AppNC'
Password:**********
Repeat Password:**********



Description

-----------

Sets the password of the user account with DistinguishedName: 'CN=mollyd,OU=AccountDeptOU,DC=AppNC' in the AD LDS instance: "dsp13a24:60000"
(user is prompted for old and new password).