Share via


How to copy files to and from Nano Server

Because SMB is often blocked by firewalls, and Remote Desktop is not supported, copying files to and from Nano Server may require a different access pattern. PowerShell Remoting over Windows Remote Management (WinRM) can provide a more secure method for copying files.

  1. Start an elevated PowerShell ISE session.

    You can do this by running the following command from any command line:

    RunAs /user:Administrator PowerShell_ISE.exe

    Alternatively, you can Ctrl+Shift+Click (or Ctrl+Shift+Double-Click) on the PowerShell ISE icon to start it with elevated (Admin) privileges. The ISE is not strictly required but it makes it easier to edit remote files (using psEdit) and remotely debug PowerShell scripts.

  2. Start the session.

    Enter the following commands into the PowerShell ISE command line:

    $ip = "192.168.0.100"  # replace with your Nano Server's IP address
    $s = New-PSSession -ComputerName $ip -Credential ~\Administrator
    
  3. Copy to Nano Server.

    To copy local files to Nano Server:

    Copy-Item -ToSession $s -Path C:\PowerShell\diag.ps1 -Destination C:\Tools\diag.ps1
    

    where:

    • -Path specifies the path on the local computer.
    • -Destination specifies the path on the remote computer. Note that the destination folder "C:\Tools" must exist prior to running the command.

    You can also copy the entire contents of a folder by specifying the folder name and the -Recurse parameter:

    Copy-Item -ToSession $s -Path C:\PowerShell\Tools\* -Destination c:\Tools -Recurse
    
  4. Copy from Nano Server.

    To copy remote files from Nano Server:

    Copy-Item -FromSession $s -Path C:\Windows\Logs\DISM\dism.log -Destination C:\PowerShell
    

    where:

    • -Path specifies the path on the remote computer.
    • -Destination specifies the path on the local computer. Note that the destination folder "C:\PowerShell" must exist prior to running the command.