How to Get Managed Account Password in SharePoint?
SharePoint Managed accounts feature was introduced in its 2010 version, and of course its a wonderful feature to manage service accounts (I remember those old days.. We used to create a batch file to update password for each and everything in SharePoint 2007!).
So, We utilized managed accounts in SharePoint 2013, enabled automatic password change. All went well until we needed the password for a particular managed account to install a third-party add-on! Luckily found this script to get managed account passwords in SharePoint.
Recover SharePoint managed account password
Here is the PowerShell script to retrieve SharePoint managed account passwords:
Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
function Bindings()
{
return [System.Reflection.BindingFlags]::CreateInstance -bor
[System.Reflection.BindingFlags]::GetField -bor
[System.Reflection.BindingFlags]::Instance -bor
[System.Reflection.BindingFlags]::NonPublic
}
function GetFieldValue([object]$o, [string]$fieldName)
{
$bindings = Bindings
return $o.GetType().GetField($fieldName, $bindings).GetValue($o);
}
function ConvertTo-UnsecureString([System.Security.SecureString]$string)
{
$intptr = [System.IntPtr]::Zero
$unmanagedString = [System.Runtime.InteropServices.Marshal]::SecureStringToGlobalAllocUnicode($string)
$unsecureString = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($unmanagedString)
[System.Runtime.InteropServices.Marshal]::ZeroFreeGlobalAllocUnicode($unmanagedString)
return $unsecureString
}
Get-SPManagedAccount | select UserName, @{Name="Password"; Expression={ConvertTo-UnsecureString (GetFieldValue $_ "m_Password").SecureStringValue}}
This script decrypts and retrieves all SharePoint 2010 / SharePoint 2013 managed account passwords along with its user names.
Related post: How to Get IIS Application Pool Password?
What is the location of passowrds ? Where are they stored and what kind of permissions account needs to get them ?
This script gets them on screen! You needs to have Farm Admin Rights.
Great Thanks!