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
Powershell
7 Comments2 Solutions160 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

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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 7 Comments.
Join the Community
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 2 Answers 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