Copying Files through Powershell RRS feed


All replies

  • Hi,

    Why are you piping to Out-File? Does the account you're running the task as have network access?

    Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)

    Monday, December 8, 2014 6:34 PM
  • There is no output from copy-item. You also need to check for errors. The task scheduler will have any errors.


    Monday, December 8, 2014 6:38 PM
  • I wanted to check if there are any errors and the account which i am using has admin rights on both of the boxes.


    Monday, December 8, 2014 6:44 PM
  • Task schedular says successfull but its actually not happening. I wanted to check for errors, not sure how can i see that


    Monday, December 8, 2014 6:45 PM
  • Use robocopy and the /log option to create a log file rather that copy-item.

    -- Bill Stewart [Bill_Stewart]

    Monday, December 8, 2014 7:21 PM
  • If you don't catch errors and abort on the error the next good line of code will erase the error.  It you add "exit" to the end of your script it will erase all errors.

    Here is how to report the first error value.  If you use exception handling you can report just the current error and exit.

        exit $firsterror.Exception.Hresult
        exit 0

    Use RoboCopy as it will keep you out of trouble


    Monday, December 8, 2014 8:26 PM