Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Invoke-Command for RoboCopy in Powershell

$
0
0

I've got an issue I'd love a bit of help with. I have a Powershell Script that is supposed to use robocopy to copy  items from one server to multiple servers simultaneously. We used to just sync in a serial manner, but that became too slow to be acceptable. Anyway, I've got credSSP enabled and working, and all of my permissions seem to be correct. However, when I run robocopy manually from the server, everything is right. When I use my script to invoke the command, everything appears to be okay, until after the Sync completes. If I go and check the robocopy logs, I have a very incomplete amount of information. When robocopy is run manually, I have about a 30 MB log file and at the very end if gives me a nice summary of what has been done. When I run it through invoke-command in powershell I get a 1 KB log file, which usually doesnt have anything more then the original robocopy information as given below

-------------------------------------------------------------------------------

   ROBOCOPY     ::     Robust File Copy for Windows                              

-------------------------------------------------------------------------------

 

  Started : Tue Aug 05 09:23:01 2014

 

   Source : \\dco-util1\Repository\content\

     Dest : E:\Data\Content\

 

    Files : *.*

   

  Options : *.* /S /E /COPY:DAT /PURGE /MIR /MT:8 /R:10 /W:30 

 

------------------------------------------------------------------------------

Here is my script: 
$User='domain\svc_account'
$pass=Get-Content c:\cred.txt | ConvertTo-SecureString
$cred=new-object System.Management.Automation.PSCredential ($user,$pass)
invoke-command -credential $cred -authentication credssp -computername "server1.domain.com", "server2.domain.com" -scriptblock {c:\windows\system32\robocopy.exe \\dco-util1\Repository\content E:\Data\Content /MIR /MT /LOG:E:\LogFiles\ContentSync\ContentSyncJob.txt /R:10}
Like I said, if I take whats inside of the scriptblock and run it on each server, things work perfectly. Can anybody help me understand why things aren't working when invoked from powershell?

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles