• Loading...
ComponentPro UltimateSftp

Use Ultimate Sftp in PowerShell

Language Filter: AllSend comments on this topic to ComponentPro

With only few steps, you can easily and quickly use Ultimate Sftp component in PowerShell as described below:

Loading assembly

To load Ultimate SFTP component for using in PowerShell, simply use the [Reflection.Assembly]::LoadFrom command as demonstrated below:

PowerShell - Loading Assembly
PS C:\> [Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\ComponentPro\UltimateSftp vX.X.X.X\Bin\Net\ComponentPro.Sftp.dll")

Loading the assembly from GAC

PowerShell - Loading Assembly from GAC
PS C:\> [Reflection.Assembly]::LoadFrom("ComponentPro.Sftp, Version=X.X.X.X, Culture=neutral, PublicKeyToken=0efede2d78b28dff")

Using Sftp or Scp class

Now you are ready to use all classes inside the Ultimate SFTP component. For example, to Connect, Authenticate and Download a file from a server, you can use the following script:

PowerShell - Using ComponentPro.Sftp
PS C:\> $client = New-Object ComponentPro.Net.Sftp

PS C:\> $client.Connect("myserver")

PS C:\> $client.Authenticate("user", "pass")

PS C:\> $client.DownloadFile("/test.dat", "c:\temp\test.dat")

PS C:\> $client.UploadFile("c:\temp\test.dat", "/test2.dat")

PS C:\> $client.DeleteFile("/test2.dat")

PS C:\> $client.Disconnect()

PS C:\> $client.Dispose()