我想使用Copy-Item
复制文件并覆盖它。但这会返回一个错误。
Copy-Item:不能用自身覆盖项目
$folder = "C:\XX"
$file = Get-ChildItem -Path "$folder\*.txt"
$count = 1
$Get = Get-Random -InputObject $file-Count $count | Where-Object LastWriteTime
$CopyFile = Copy-Item $Get -Destination "$folder" -Recurse -Force