Click here to Skip to main content
969 members (224 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

7.1K views
Posted 18 Apr 2012

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

, 18 Apr 2012
Rate this:
Please Sign up or sign in to vote.
When Secure Copy Protocol (SCP) is enabled on the PowerShell Server, an SCP client can connect and upload or 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:

  1. On the Connection tab simply check the box that says "Enable Secure Copy Protocol (SCP) Support".
  2. 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

Included with the PowerShell Server are several cmdlets, 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:

As of PowerShell Server V5 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

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

powershellscripter
United States United States
No Biography provided
Group type: Organisation (No members)



You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
RA-Web1 | 2.8.170713.1 | Last Updated 18 Apr 2012
Article Copyright 2012 by powershellscripter
Everything else Copyright © RootAdmin, 1999-2017
Layout: fixed | fluid