I need to copy file from one remote server to other using powershell script.
What I have tried :-
While i use following powershell commands it's work fine.(means file copied from one server to other)
But while i use following script it gives error "cannot find path..." as follows
Actually, file is exist at that path.
I have tried to refer following stack-overflow already question-answer
- Error with PowerShell command for copying file to remote server with credential
- 'Session' Parameter is null or empty in PowerShell script
- powershell remote
- Invoke-Command with remote session: Cannot validate argument on parameter
- Unable to copy a binary to a remote Azure VM
- PowerShell Command to Copy File on Remote Machine
I have also tried to get help using
Get-Help Invoke-Command
Question :-
- How can i use "Copy-Item" command inside "Invoke-Command(Scriptblock)" in script(2) to copy file?
- Is there any better way to achieve this(means best practice)?