troubleshooting Question

Copy-item script not working properly

Avatar of Chris Cadey
Chris CadeyFlag for United Kingdom of Great Britain and Northern Ireland asked on
7 Comments1 Solution161 ViewsLast Modified:
having problems getting my script to work. it fundamentally needs to copy an app folder from the server and drop it to the workstations, so I'm using a script to achieve this. however its throwing up multiple errors of the same type, weirdly some files copy ok.

Heres the script :

$pw = ConvertTo-SecureString -AsPlainText -Force -String xxxxxx
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "xxxx\xxxx",$pw
$Session = New-PSSession -ComputerName "server" -Credential $cred
Copy-item -FromSession $Session -Path "D:\xxxxx\Apps" -Destination "C:\xxxxx" -Recurse

Open in new window

Heres the errors :

Copy-item : Method invocation failed because [System.IO.MemoryStream] does not contain a method named 'new'.
At line:4 char:1
+ Copy-item -FromSession $Session -Path "D:\xxxxx\Apps" -Destination  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], RuntimeException
    + FullyQualifiedErrorId : System.Management.Automation.RuntimeException,WriteException

Open in new window

Director of Information Technology

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros