Showing posts with label Secure Store. Show all posts
Showing posts with label Secure Store. Show all posts

Tuesday, April 24, 2018

GET all Credentials from Secure Store Service

Before some time i need to find out credentials which are used in Secure Store service and this script helped me.

******************************

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$serviceCntx = Get-SPServiceContext -Site http://YourIntranetSiteURL
 $sssProvider = New-Object Microsoft.Office.SecureStoreService.Server.SecureStoreProvider
 $sssProvider.Context = $serviceCntx
 $marshal = [System.Runtime.InteropServices.Marshal]

try
  {
  $applicationlications = $sssProvider.GetTargetApplications()
  foreach ($application in $applicationlications)
  {
  Write-Output "`n$($application.Name)"
  Write-Output "$('-'*100)"

try
  {
  $sssCreds = $sssProvider.GetCredentials($application.Name)
  foreach ($sssCred in $sssCreds)
  {
  $ptr = $marshal::SecureStringToBSTR($sssCred.Credential)
  $str = $marshal::PtrToStringBSTR($ptr)
 Write-Output "$($sssCred.CredentialType): $($str)"
  }
  }

catch
  {
  Write-Output "(Something went wrong) - Error getting credentials!"
  }
  Write-Output "$('-'*100)"
  }
  }

 catch
  {
  Write-Output "(Something went wrong) - Error getting Target Applications."
  }

******************************

Output should look something like this