@Frittenreinhold: The PowerShell code will be pretty much an equivalent of the C# code above:
$session.PutFile(New-Object System.IO.MemoryStream, "/remote/path/file.txt")