In an environment with good security practice applied, you’ll likely find you can’t copy files to a secure server over RDP or via the usual methods:
- UNC to the server (
- RDP via clipboard (
con your client,
von the server)
- RDP via redirected drive (
Fortunately, WMF5 brings a new capability to PowerShell; the ability to copy files into and out of a PowerShell session. This is super easy to demonstrate:
$session = New-PSSession -ComputerName MyServer Copy-Item -Path "C:\myfile.txt" -Target "C:\SomeServerFolder" -ToSession $session
You can use the
Copy-Item cmdlet as per normal, just add the
-ToSession parameter and pass in a PowerShell session. You’ll even get a pretty progress bar if you decide to copy large or multiple files.
There's no commenting functionality here. If you'd like to comment, please either mention me (@[email protected]) on Mastodon or email me. I don't have any logging or analytics running on this website, so if you found something useful or interesting it would mean a lot to hear from you.