Viewing 1 reply thread
  • Author
    Posts
    • #173161
      Participant
      Topics: 5
      Replies: 6
      Points: 27
      Rank: Member

      Hello,

      I am trying to run a simple powershell script to copy all changed files to another server as it is not in a domain so using DFS is not an option. The script is as follows,

      
      $Source = gci “Path” -Recurse | Where-Object{$_.Name -notlike “*.log”}
      $Dest = “\\IP\e$”
      $Username = “USERNAME”
      $Password = get-content “PATH” | convertto-securestring
      $mycreds = New-Object System.Management.Automation.PSCredential($Username, $Password)
      $Logfile = “PATH\Filesync_$todays_date.log”
      
      #Delete log file if larger than 1GB
      Get-ChildItem “PATH” | Where-Object{$_.Length -gt 1gb} | Remove-Item
      
      #Copy data to Server
      New-PSDrive -Name x -PSProvider FileSystem -Root $Dest -Credential $mycreds
      Robocopy $Source $Dest /MIR /log:$Logfile
      Remove-PSDrive -Name X
      
      

       

      My issue is that i get the below error. From what i can see this is a name length issue with powershell. I cannot change the file names as they are used by the application. Is there another way to get round this?

    • #173185
      Participant
      Topics: 0
      Replies: 115
      Points: 433
      Helping Hand
      Rank: Contributor

      Hello Leon,

      Looks like the error message didn’t come through. Please upload the error message as well for review. You can use /XF selection option to exclude the log files. Example below.

      Robocopy.exe $Source $Destination /XF *.log
Viewing 1 reply thread
  • The topic ‘Robocopy’ is closed to new replies.