Pergunta

Im writeing a backupscript useing powershell. I know that i could just use robocopy or rsync but i would like to do this in powershell. The problem i have has to do with the copy-item cmdlet. What my script does:

  • Read var's and fills them from a csv
  • Pings destination host
  • Checks if Outlook is open on source host and asks if it should close it
  • Then it should copy some folders onto the destination

My problem is that it always does a full copy of all files. I would like it to only copy the files that were changed or do not exist on the destination.

The second problem i have is that in Win7 there are hidden systemfolders in "Users/Documents" that link to "My Pictures" and "My Videos". I dont need to copy these but i didnt manage to exclude them useing the exclude agrument.

Foi útil?

Solução

Just some quick and general suggestion...

  • I would like it to only copy the files that were changed

    I would copy the files comparing the source and destination modified date

  • The second problem i have is that in Win7 there are hidden systemfolders in "Users/Documents" that link to "My Pictures" and "My Videos". I dont need to copy these but i didnt manage to exclude them useing the exclude agrument. :

    Do not use copy-item directly, but use the output of get-childitem without force parameter. This will prevent to copy hidden or system files.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top