Copy-Item is overwriting by default

When in doubt, read the documentation.

-Force

Allows the cmdlet to copy items that cannot otherwise be changed, such as copying over a read-only file or alias.

The default behavior for Copy-Item is to replace existing items. The -Force switch is only to enforce replacement if for instance the destination file has the readonly attribute set.

You can use -Confirm to get prompted before Copy-Item performs the operation, or you can use -WhatIf to see what the cmdlet would do.

Leave a Comment