Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Copy Files with PowerShell Remoting WINRM Protocol

Microsoft Powershell psremoting is just not limited to remoting into computers, it can also use to Copy files over Winrm Protocol to remote system the same way, you use files are copied on traditional SMB protocol. This requires some psremoting configuration using POWERSHELL PS REMOTING BETWEEN COMPUTERS. To show everything from scratch I have listed my files using dir command from local folder and remote computer folder. I will copy one of the ISO file to remote server.

PS remoting is session based so I will create a new session first. whoami command shows the current logged in user, Session is created with same account, If another username or password need to use, provide parameter -Credential (Get-Credential) with below command.
$PSSession = New-PSSession -ComputerName Server01 

And next command will copy the file remotely over winrm protocol, it will take some time depending on the size of file to copy and will show copy progress. File once copied verify it with dir again that file exist on remote folder.
Copy-Item -Path .\Router.iso -Destination c:\temp -ToSession $PSSession

Once everything is  verified, close and remove session using
Remove-PSSession $PSSession

Useful Articles
Different ways to bypass Powershell execution policy :.ps1 cannot be loaded because running scripts is disabled
Installing, importing and using any module in powershell

This post first appeared on Tales From Real IT System Administrators World And Non-production Environment, please read the originial post: here

Share the post

Copy Files with PowerShell Remoting WINRM Protocol


Subscribe to Tales From Real It System Administrators World And Non-production Environment

Get updates delivered right to your inbox!

Thank you for your subscription