Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

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

Microsoft windows Powershell, winrm, wsman, dir, get-childitem, new-pssession, whoami, remove-pssession, copy-item psremoting, enable psremoting

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
GUI - SETUP AND CONFIGURE POWERSHELL WEB ACCESS SERVER (GATEWAY)

Go Back

Comment

Blog Search

Page Views

1171982

Follow me on Blogarama