Protecting credentials used for automation
Hello,
I've already read the information about the Protecting of credentials. 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:
and
and
Can someone provide me a complete example, not only these fragments?
Thanks,
Moritz
I've already read the information about the Protecting of credentials. 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 }
Read-Host -AsSecureString | ConvertFrom-SecureString
$sessionOptions.SecurePassword = ConvertTo-SecureString $config.Configuration.Password
Thanks,
Moritz