Excluding a file while using Copy-Item

This topic contains 1 reply, has 2 voices, and was last updated by  Tim Pringle 2 years, 6 months ago.

  • Author
  • #33455

    nemo nemo

    Hey Guys I having a bit of issues while copying desktop files as a part of the back up process from local folder to server.

    So my Script automatically creates a Backup folder and i just realise when it creates the back up folder windows automatically creates a desktop.ini file and as desktop.ini is a system file the script failed to write another desktop.ini from desktop to the backup folder in server.

    so My initial code was :

    Copy-Item ("$Global:localBackupRestoreLocation\Desktop\$file") ("$Global:remoteBackupRestorePath\$nameOfbackupDirectory") ($recursive="true")

    But I was to use the exclude in that line and i know exclude does not work recursive and i have to use get child-item.. can any one give me hand ..cheers

  • #33468

    Tim Pringle

    Hey Nemo Nemo,

    Have you tried using -ErrorActionPreference 'Continue' in your Copy-Item command?

You must be logged in to reply to this topic.