Retrieving/Recovering Secure Store Credentials

I had the need to find the username/password that was saved into a secure store group credential.  After some research I was able to create a script that did the job:

$SecureStoreProvider=[Microsoft.Office.SecureStoreService.Server.SecureStoreProviderFactory]::Create()
$site = Get-SPSite -Identity $(Get-SPWebApplication -IncludeCentralAdministration | ?{ $_.IsAdministrationWebApplication}).Url
$SecureStoreProvider.Context = Get-SPServiceContext -Site ($site)
$SecureStoreProvider.GetTargetApplications() |  ForEach-Object {
	Write-Host $_.Name
	try {
		$SecureStoreProvider.GetCredentials($_.ApplicationId) | ForEach-Object {
			$Credential = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($_.Credential))
			Write-Host "`t$($_.CredentialType): $($Credential)"
		}
	} catch  {
		Write-Host "`t$($_)"  -ForegroundColor yellow
	}
}

Advertisements
Posted in PowerShell, Quick Tip, SharePoint 2010, SharePoint 2013

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: