using .ini vs SessionOptions Powershell

Advertisement

giermo
Joined:
Posts:
9

using .ini vs SessionOptions Powershell

Hello
I have a bunch of scripts getting and putting files to a ftp and sftp server using the sessionOptions.XXX commands in a powershell script.

I would like to use the .ini file instead, so that login credentials are better protected, versus being plain text in all the scripts. (can i have seperate ini files per ftp server?)

So far i got this:
$session = New-Object WinSCP.Session
($session).IniFilePath
I am new to PS, and see there is a get and set option for the IniFilePath Property

I have been however unable to implement this. (i used the gui to creat a .ini file to persuse as well)

I am stuck on how to implement this correctly.

Any syntax aid would be great.

Thanks

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

Re: using .ini vs SessionOptions Powershell

Using an INI file is not protecting your passwords. It's just obfuscating them.
See https://winscp.net/eng/docs/security_credentials#storing_password

You can implement your own obfuscation and read just credentials from some configuration file of your own, instead of using whole WinSCP INI file (It may cause you lot of troubles). Even better you can protect your configuration file with Windows file-level encryption and make it accessible with restricted account only (you can do the same with INI file obviously, or even easier, do it with your present scripts).

Anyway, to answer your question. I actually do not know what you are asking for. The Session.IniFilePath is a string property. Just set it with path to the INI file you have created with GUI.

Reply with quote

giermo

thanks

Okay thanks. Yeah, my plan was to now just create my own text file and parse it to get the credentials i need, .ini was too much of a complication lol

Thanks for the quick response. :)

Reply with quote

Advertisement

You can post new topics in this forum