PowerShell Export Script

Here is an example of a PowerShell script that exports all of your secrets into a text file. Note that the you will need PowerShell 2.0 (and not the default 1.0) installed to run the script. Replace the relevant parameters with your own values:

For Version 8.2 and higher:
$outputFile = 'enter output file path here'
$username = 'enter username here'
$password = 'enter password here'
$domain = ''
$url = 'https://yoursecretserverurl/webservices/sswebservice.asmx'
$proxy = New-WebServiceProxy -uri $url -UseDefaultCredential
$token = $proxy.Authenticate($username, $password, '', $domain).Token
$secrets = $proxy.SearchSecrets($token, '', $null, $null).SecretSummaries
$sb = new-object system.text.stringBuilder
foreach ($secret in $secrets) {
    $currentSecret = $proxy.GetSecret($token, $secret.SecretId, $false, $null)
    $sb.Append(($currentSecret.Secret|out-string))
    $sb.Append(($currentSecret.Secret.Items|out-string))
}
$sb.ToString() > $outputFile


For Version 8.1.000014 and lower:
$outputFile = 'enter output file path here'
$username = 'enter username here'
$password = 'enter password here'
$domain = ''
$url = 'https://yoursecretserverurl/webservices/sswebservice.asmx'
$proxy = New-WebServiceProxy -uri $url -UseDefaultCredential 
$token = $proxy.Authenticate($username, $password, '', $domain).Token
$secrets = $proxy.SearchSecrets($token, '').SecretSummaries
$sb = new-object system.text.stringBuilder
foreach ($secret in $secrets) {
    $currentSecret = $proxy.GetSecret($token, $secret.SecretId)
    $sb.Append(($currentSecret.Secret|out-string))
    $sb.Append(($currentSecret.Secret.Items|out-string))
}
$sb.ToString() > $outputFile

Article ID: 155, Created On: 4/13/2011, Modified: 9/4/2013

Feedback (0)