Protecting credentials used for automation

Advertisement

BR365
Joined:
Posts:
1

Protecting credentials used for automation

Hello,
I've already read the information about the Protecting of credentials (https://winscp.net/eng/docs/guide_protecting_credentials_for_automation). But I still don't know exactly how to put all this together.

At the moment, I have a batch file and a config file. The Batch is defining some standard path informations and the config file manages the SFTP transfer.

I also understand how to encrypt the password and created an XML file as shown in the example with the encrypted password.

But how can I now use this part:

# Read XML configuration file
[xml]$config = Get-Content ".\config.xml"
 
# Use read credentials
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "example.com"
    UserName = $config.Configuration.UserName
    Password = $config.Configuration.Password
}

and

Read-Host -AsSecureString | ConvertFrom-SecureString

and

$sessionOptions.SecurePassword = ConvertTo-SecureString $config.Configuration.Password

Can someone provide me a complete example, not only these fragments?

Thanks,
Moritz

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
34,115
Location:
Prague, Czechia

Re: Protecting credentials used for automation

I have updated the article for more clarity.

For a more specific example of use of the Read-Host ..., see also the C# section of the article.

Reply with quote

Advertisement

You can post new topics in this forum