Retrieve SharePoint Account Password
Found interesting scripts over Microsoft Gallery and re sharing
$ver = $host | select version
if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
##
#This Script Retrieves The Password for a specific SharePoint Managed Account
##
##
#Begin Setting Script Variables
##
$AccountToRetrieve = "Domain\User"
##
#Begin Script
##
#Retrieve the SharePoint farm
$Farm = get-spfarm | select name
#Get the Configuration Database from the farm
$Configdb = Get-SPDatabase | ? {$_.name -eq $Farm.Name.Tostring()}
#Get the Managed Account we defined as a script variable
$ManagedAccount = get-SPManagedAccount $AccountToRetrieve
#Retrieve the password, assign it to a variable
$Password = cmd.exe /c $env:windir\system32\inetsrv\appcmd.exe list apppool "Password Retrieval" /text:ProcessModel.Password
#Output the Password to the screen for the administrator
Write-Host "Password for Account " $AccountToRetrieve " is " $Password
$ver = $host | select version
if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
##
#This Script Retrieves The Password for a specific SharePoint Managed Account
##
##
#Begin Setting Script Variables
##
$AccountToRetrieve = "Domain\User"
##
#Begin Script
##
#Retrieve the SharePoint farm
$Farm = get-spfarm | select name
#Get the Configuration Database from the farm
$Configdb = Get-SPDatabase | ? {$_.name -eq $Farm.Name.Tostring()}
#Get the Managed Account we defined as a script variable
$ManagedAccount = get-SPManagedAccount $AccountToRetrieve
#Retrieve the password, assign it to a variable
$Password = cmd.exe /c $env:windir\system32\inetsrv\appcmd.exe list apppool "Password Retrieval" /text:ProcessModel.Password
#Output the Password to the screen for the administrator
Write-Host "Password for Account " $AccountToRetrieve " is " $Password
Comments
Post a Comment