Change password of a Managed Account in SharePoint
You might found a lot of scripts for doing the same task in SharePoint 2010 Managed Shell. But I would add on to the problem I faced in changing the password after listing the command for the same.
Following is the algorithm to change the password:
- Get the appropriate managed account.
- Get the password and change the password to secure string.
- Set the password.
Step 1: Get Desired Managed Account
Use the following command to get the managed account.
$managedAccount = Get-SPManagedAccount -Identity "username"
Step 2: Get the Password and change the password to secure string
Passwords are accepted as SecureString, so we need to create an object of SecureString from password string. So, we would create the secure string object in the following way.
$pwd = ConvertTo-SecureString "<Password>" -AsPlainText -force
Note: If in case the password has ` character in the password for example, if the password is “pwd`123” then we need to append an extra ` character, so the password string would be “pwd“123” instead. In a crux, ` is an escape character in PowerShell.
Step 3: Set the password
Now, set the password using the following command.
Set-SPManagedAccount -Identity $managedAccount -ExistingPassword($pwd)
Note: The above scenario would only change the password of Managed Account with the current password. It won’t change password in AD.