Password using XML config file
Hello all!
I have successfully created a syntax that uses the WinSCPnet.dll (.NET assembly).
Also, a
I do this successfully with everything except the password!
Here is the script that works:
I cannot get it to work by replacing the
The error message:
Any help would be greatly appreciated!
Thank you
I have successfully created a syntax that uses the WinSCPnet.dll (.NET assembly).
Also, a
config.xml
file has been created to provide the credentials and start the session.
I do this successfully with everything except the password!
Here is the script that works:
[xml]$Config = Get-Content "*\Config.xml" # Load WinSCP .NET assembly Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll" # Set up session options $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = $Config.Configuration.HostIP UserName = $Config.Configuration.UserName Password = "Actual Password" PrivateKeyPassphrase = $Config.Configuration.PassPhrase SshHostKeyFingerprint = $Config.Configuration.FingerPrint SshPrivateKeyPath = $Config.Configuration.SshPrivateKeyPath }
"Actual Password"
with $Config.Configuration.Password
. Within the XML file, I have accounted for escape characters. Does anyone know of other reasons why this would not work?
The error message:
Exception calling "Open" with "1" argument(s): "Connection has been unexpectedly closed. Server sent command exit status 0. Authentication log (see session log for details): Using username "Actual Username". Authenticating with public key "imported-openssh-key" from agent. Further authentication required Access denied. Authentication failed." At *\PS_winSCP.ps1:25 char:5 + $session.Open($sessionOptions) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SessionRemoteException
Thank you