Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
Start-SPAssignment -Global # This cmdlet takes care of the disposable objects to prevent memory leak.
$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)" -ForegroundColor Red
}
} catch {
Write-Host "`t$($_)" -ForegroundColor Blue
}
}
Stop-SPAssignment -Global # This cmdlet takes care of the disposable objects to prevent memory leak.
Remove-PsSnapin Microsoft.SharePoint.Powershell