The PowerShell command Copy-Item will overwrite a file if it exists by default. This is unless that file is marked Read Only in which case you can use the -Force switch to overwrite the file.
What if you want to only copy the file if it doesn’t exist? Here’s a quick PowerShell script that will complete this task:
$filefrom = 'c:tempsomething.txt' $fileto = 'c:temp1something.txt' if (-not (test-path $fileto)) { $opts = @{'path' = $filefrom; 'destination' = $fileto; 'confirm' = $false} copy-item @opts } else { $opts = @{'path' = $filefrom; 'destination' = $fileto; 'confirm' = $true} copy-item @opts }