1

On windows server core, how can I copy file located in my local computer to the windows server ?

  • Do you already know how to copy files to a Window Server that is not Server Core? – Todd Wilcox Jun 19 '18 at 19:24
4

The best way to copy file to Windows core is by using USB, and copy it. But you can use SCP protocol for remote copying, but first, you must enable SSH terminal. It is light, secure and only using port 22. SCP is Secure Copy Protocol, and runs on top of SSH (Secure Shell)

First, you need to find the version.

Get-WindowsCapability -Online |  ?{$_.Name -Like 'openssh*'}

Mine shows like:

Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

Install the server with:

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

then enable it using

Start-Service sshd
Set-Service sshd -StartupType 'Automatic'
Get-NetFirewallRule -Name *ssh* 

it should show a line like:

Enabled     : True

Then you can transfer a file using SCP protocol. One of popular client is WinSCP.

Plus, you can use it to manage your server from remote locations using powershell terminal. Make sure you harden your ssh server to publickey if you want to keep it, though. Also, restrict administrator access, and use New-PSSession to switch to administrator mode. It is linux de-facto protocol for managing OS, so I can vouch for its security. One of popular SSH client is Putty.

With SSH, you only need to open putty for powershell terminal, or winscp to copy file.

| improve this answer | |
2

With the command-line copy command, perhaps.

Here's the interactive help for it:

 C:\>copy /?
 Copies one or more files to another location.

 COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B]
      [+ source [/A | /B] [+ ...]] [destination [/A | /B]]

  source       Specifies the file or files to be copied.
  /A           Indicates an ASCII text file.
  /B           Indicates a binary file.
  /D           Allow the destination file to be created decrypted
  destination  Specifies the directory and/or filename for the new file(s).
  /V           Verifies that new files are written correctly.
  /N           Uses short filename, if available, when copying a file with a
               non-8dot3 name.
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.
  /L           If the source is a symbolic link, copy the link to the target
               instead of the actual file the source link points to.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.  Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.

To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).

C:\>

Or were you referring to where to copy it?

If you have admin credentials, you can use an administrative share, which would be \\<server name>\c$ for the root of the C: drive on the server. You can get to the root of other drives the same way.

Or you can use server manager to create a share. Or you can use Computer Management to create a share.

In Windows Explorer on your computer - not the server open up the folder containing the file to you want to copy. Go to Start -> Run and type in \\<name of the server>\c$ and hit Enter. That should open a new explorer window showing the C: drive on the server - if it asks for a username and password, enter your administrator account credentials on the server. Now you can copy and paste from one explorer window to the other like normal.

| improve this answer | |
  • thanks todd, but how to do ? – loki Jun 19 '18 at 19:23
  • no i still not see how to do :( i m under remote desktop – loki Jun 19 '18 at 19:33
  • @loki Do you know how to copy files from one machine to another when the server is not server core? – Todd Wilcox Jun 19 '18 at 19:36
  • I do with Ctrl-C / Ctrl-V and total commander – loki Jun 19 '18 at 19:38
  • 2
    @loki See my edit. You might consider adding the GUI to the server core so that it's easier for you to work with. – Todd Wilcox Jun 19 '18 at 19:41
0

This is not an ideal answer but for quick moving file between local and remote server core.

  1. Enable ssh on server core
  2. Using winscp to quick drag & drop file from local to server.

The server core itself must support ssh of course.

| improve this answer | |
0

You could use SMB to open the c$ share on the server \\server1\c$ if you are an administrator and the firewall isn't set to block file sharing.

Likewise, you can launch powershell and run the following command to tell the remote server to copy a file from your local computer using SMB.

Copy-Item –Path C:\Folder1\file1.txt –Destination '\\your-client1\c$\filetocopy'

Alternatively, if you have enabled WinRM for remote powershell execution you can copy over powershell using:

$session = New-PSSession –ComputerName SERVER1
Copy-Item –Path C:\Folder1\file1.txt –Destination 'C:\' –ToSession $session

WinRM can be tricky to setup, especially for non-domain computers but it's worth it for remote administration if you have multiple computers/servers.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.