Excluding a file while using Copy-Item

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

Hey Nemo Nemo,

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