PowerShell Server: Using Secure Copy Protocol (SCP) To Upload and Download Files

When Secure Copy Protocol (SCP) is enabled on the PowerShell Server, an SCP client can connect and upload or download files. Below is a description of a variety of common methods used to send and receive files over SCP with the PowerShell Server.


Enabling SCP

By default, the PowerShell Server does not allow SCP connections. This is easily enabled in the server interface using the following steps:

On the Connection tab simply check the box that says “Enable Secure Copy Protocol (SCP) Support”.
Then click Save Changes and Restart to restart the server with this change.
That is all that is required to enable SCP support. Now you can connect using any of the methods described below.


SCP From PowerShell Server Cmdlets

The community edition of NetCmdlets (netcmdlets.com) are several cmdlets designed to work with PowerShell Server, including Get-PowerShellServerFile and Send-PowerShellServerFile. These two cmdlets will allow you to send and receive files from PowerShell Server when SCP is enabled. The usage is very simple. For example:

Uploading a File

PS> Send-PowerShellServerFile -Server YourServer -RemoteFile C:\temp\test.txt 
-LocalFile C:\downloads\test.txt

Downloading a File

PS> Get-PowerShellServerFile -Server YourServer -RemoteFile C:\uploads\test.txt 
-LocalFile C:\temp\test.txt

Notes:

The default authentication mechanism when using the Send-PowerShellServerFile and Get-PowerShellServerFile cmdlets is GSSAPI using NTLM and Kerberos.

When the client and server machine are on the same domain, and the user is a member of the appropriate security group, this means that no explicit authentication parameters are required. While this is convenient, if you need to use regular password authentication and specify the user and password when connecting this can be done by specifying the AuthMode, User, and Password parameters. For instance:

PS> Send-PowerShellServerFile -Server YourServer -AuthMode password -User MyUser
-Password MyPassword -RemoteFile C:\temp\test.txt -LocalFile C:\downloads\test.txt

WinSCP behaves in a way that is not standard to SCP, and since the SCP functionality built into PowerShell Server is strictly SCP, connections from WinSCP to PowerShell Server over SCP are not supported.

SCP From Linux

The command line SCP client in Linux can also be used to send and get files.

Uploading a File

test@server:~/> scp -oUser=DOMAIN\user ./test.txt hostname:c:\temp\test.txt

Downloading a File

test@server:~/> scp -oUser=DOMAIN\user hostname:c:\temp\test.txt ./test.txt

Notes:

In the above examples two special requirements are demonstrated.

  • When using SCP on Linux and need to authenticate with a windows domain
    username you must explicitly set the username using -oUser as above.
  • Paths containing backslashes must be escaped with another backslash.

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.