Author Posts

January 26, 2016 at 5:19 pm

Hello,

I have grabbed the following code off of the posh-ssh site that i am trying to use to connect to an SFTP site and download the contents of a folder. it is prompting me for the site name and such. why is it not grabbing the information from $sftpsession?

Thanks,

Derek

$sftpUser = “sftpuser”
$sftpPass = ConvertTo-SecureString -String “password” -AsPlainText -Force
 $sftpCred = new-object -typename System.Management.Automation.PSCredential -argumentlist $sftpUser, $sftpPass
 $sftpSession = New-SFTPSession -ComputerName sftp.site.com -Credential $sftpCred -Port 2000

Get-SCPFolder   -LocalFolder "C:\folder\" -remotefolder "/folder/" 

$sftpSession.Disconnect()
 Get-SFTPFile : Object reference not set to an instance of an object

January 26, 2016 at 7:53 pm

You might actually ask on that site, but at a guess, I don't see you passing the session to the command. I'd imagine there's a parameter for doing so.