2

When I try to copy files from the remote machine to local machine, I get the error:

Copy-Item : A parameter cannot be found that matches parameter name 'FromSession'.

I copy files to the same drive and the drive and path exists in both the machine.

Is this expected behavior?

$sessions = New-PSSession -ComputerName "xxxxxx"
$sessions | ForEach-Object { Copy-Item -FromSession $_ -Path c:\Test2\\*.txt -Destination C:\Test2 }
Matt
  • 45,022
  • 8
  • 78
  • 119
shanmuga raja
  • 685
  • 6
  • 19

1 Answers1

0

This seems like either unintended behavior or unexpected starting conditions. Testing an analog of this in my environment works perfectly. My suggestion would be two-fold:

I would do something like this against a list of computers it's happening on to confirm for certain they're on 5.1

Invoke-command -ComputerName $ComputerList {$PSversionTable.Psversion}

Beyond that, if the behavior continues I'm unsure of a way to resolve it, but depending on what you're trying to do it may be plausible to work around it outside of PSsessions, unless you're using PSSessions to gain access to some cmdlets or credentials you don't have under your standard Shell. It may look something like this

Copy-Item -path "\\$Computername\C$\Test2\*.txt" -destination "C:\test2"
Chakani
  • 101
  • 4
  • You need to explicitly create a shared folder in the remote machine in order to run the script without session. Is that correct? – shanmuga raja Oct 18 '18 at 22:38
  • No, as long as you're on the same domain and using an account with the correct permissions, (or off the domain and using explicit credentials that do have access to the relevant machine(s) you should be able to copy to and from it without placing a file on it. – Chakani Oct 19 '18 at 20:29