我有以下结构:
C:\one\web.config
C:\two\web_rollback.config
C:\three\ ( this is empty , it is where I want to copy to
在我的 Powershell file.ps1 我有以下代码:
$Folder1 = Get-childitem "C:\one\"
$Folder2 = Get-childitem "C:\two\"
$Folder3 = Get-childItem "C:\three\"
Compare-Object $Folder1 $Folder2 -Property Name, Length | Where-Object {$_.SideIndicator -eq "=>"} | ForEach-Object {
Copy-Item "$Folder1\$($_.name)" -Destination $Folder3 -Force}
但是,我在为什么下面收到此错误?
PS C:\windows\system32> C:\pscripts\compareobject.ps1
Copy-Item : Cannot find path 'C:\windows\system32\Web.config\Web_Rollback.config' because it does not exist.