Today, we are going to see how to copy a file to remote destination using WINRM. Traditionally SMB Protocol (File Sharing \\Servername\C$) was used to transfer the files but nowadays you will find SMB Protocol disabled on some servers so you will require firewall changes to perform that.
On the other hand WINRM Protocol 5985 is mostly open for Powershell Remote sessions, so we will use that to transfer the files.
Lets get started :
Step 1 : Create a PS Session for that server
$Session = New-PSSession -ComputerName <ServerName>
Step 2 : Use Copy-Item with -ToSession to transfer the file using WINRM
Copy-Item -Path C:\Scripts\Amar\TestFile.txt -ToSession $Session -Destination "D:\"
TestFile.txt file will get copied from local system to the D Drive of the remote server.
Happy Learning :)
Post a Comment