Transfer files via Powershell Remoting (like scp in linux)

Solution 1:

You can easily copy the contents of a file over-the-wire through a PSRemoting session using Invoke-Command and Set-Content:

$Session = New-PSSession -ComputerName "remotehost.domain.tld" -Credential (Get-Credential) -UseSsl

$FileContents = Get-Content -Path 'C:\path\to\arbitrary.file'
Invoke-Command -Session $Session -ScriptBlock {
    param($FilePath,$data)
    Set-Content -Path $FilePath -Value $data
} -ArgumentList "C:\remote\file\path.file",$FileContents

Solution 2:

New in PowerShell 5.0: Copy-Item now comes with -ToSession and -FromSession parameters!

More details and examples here: Copy To or From a PowerShell Session