how to use a stored session with powershell

Advertisement

wleddy
Joined:
Posts:
2

how to use a stored session with powershell

Is there a way to reference a stored session when using powershell?

$session.Open($sessionOptions)
requires having the plain text password to use when building $sessionOptions, something I saved as a stored session so I wouldn't need it.

Is there a form something like
$session.OpenSession($sessionName)
to use all the settings available for the GUI session?

Or a callable method that will return the decrypted password given a session name, which could be used in building $sessionOptions?

Thanx,
Bill

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: how to use a stored session with powershell

wleddy wrote:

Is there a way to reference a stored session when using powershell?
WinSCP .NET assembly is deliberately isolated from WinSCP configuration by default. While you can hack it to use the stored session/site, I would not recommend it.

$session.Open($sessionOptions)
requires having the plain text password to use when building $sessionOptions, something I saved as a stored session so I wouldn't need it.
That's not a good argument. Note that the password stored in the stored session/site can be easily recovered too. You need to ensure safety of your machine to protect the password.
See https://winscp.net/eng/docs/security_credentials

Reply with quote

wleddy

Thanx for the reply. I have a work around saving (get-credential).password as a secure string file and then converting *that* to text. I was hoping for something less cumbersome (among other things, this requires the service account that is running the scheduled tasks of interacting with a remote SFTP server to have local log-on privs in order to save the secure string, something which has its own security risks) but I can appreciate the need for password security.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

wleddy wrote:

Thanx for the reply. I have a work around saving (get-credential).password as a secure string file and then converting *that* to text. I was hoping for something less cumbersome (among other things, this requires the service account that is running the scheduled tasks of interacting with a remote SFTP server to have local log-on privs in order to save the secure string, something which has its own security risks) but I can appreciate the need for password security.
Running this under special account to protect the credentials is IMHO the only correct way.

Reply with quote

Advertisement

You can post new topics in this forum