Changing SharePoint 2010 Managed Account Passwords with PowerShell

A SharePoint 2010 Managed Account, is essentially a Service Account whose credentials are managed by SharePoint, which can automatically change the password of the account based on a given policy / schedule. Check out the posting “Managed Accounts” in Bill Baer’s Blog for more detailed information.

While most of the configuration of managed accounts will likely take place in Central Administration, at some point you may need (or simply prefer) to change the password via PowerShell. Personally, I ran into the need, as my farm account password had been changed and the Central Administration site would not run.

I used the following PowerShell script to change the Managed Account password.

$ver = $host | select versionif ($ver.Version.Major -gt 1)  {$Host.Runspace.ThreadOptions = ReuseThread"}Add-PsSnapin Microsoft.SharePoint.PowerShellSet-location $home

$inManagedAcct = Read-Host 'Service Account'

$managedAcct = Get-SPManagedAccount $inManagedAcct

$inPass = Read-Host 'Enter Password' -AsSecureString$inPassConfirm = Read-Host'Confirm Password' -AsSecureString

Set-SPManagedAccount -Identity $managedAcct -NewPassword $inPass -ConfirmPassword $inPassConfirm -SetNewPassword

Click here to download the PS1 file. You may need to remove the first few lines that load the SharePoint PowerShell snap-in, if you intend to run the script from the “SharePoint 2010 Management Shell” console.


What’s my SharePoint 2010 Content Database ID?

There are several commands that may require you to pass in a SharePoint Content Database ID. PowerShell makes it easy, just use the Get-SPContentDatabase command.

Pass in the WebApplication Parameter to get a list of all of your Content Databases for that Web Application:

image 

Need to know the Content Database of a specific site (web)? Just pass in the site parameter:

image

For a complete list of SharePoint 2010 Content Database Powershell cmdlets go to http://technet.microsoft.com/en-us/library/ee890116(office.14).aspx

digg_url = “http://blog.rafelo.com/2010/03/whats-my-sharepoint-2010-content.html”;digg_title = “What’s my SharePoint 2010 Content Database ID?”;digg_bgcolor = “#FFFFFF”;digg_skin = “compact”;digg_url = undefined;digg_title = undefined;digg_bgcolor = undefined;digg_skin = undefined;

Follow

Get every new post delivered to your Inbox.