Excluding a file while using Copy-Item

Welcome Forums General PowerShell Q&A Excluding a file while using Copy-Item

This topic contains 1 reply, has 2 voices, and was last updated by

3 years, 4 months ago.

  • Author
  • #33455

    Topics: 2
    Replies: 1
    Points: 0
    Rank: Member

    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

    Topics: 4
    Replies: 262
    Points: 60
    Rank: Member

    Hey Nemo Nemo,

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

The topic ‘Excluding a file while using Copy-Item’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort