我想让PowerShell从远程计算机(我通过AD拥有管理员权限)复制文件到本地计算机。它在最奇怪的地方失败了。以下是脚本的一部分:
它会失败并显示消息。
$configs = Get-ChildItem -Recurse -ErrorAction SilentlyContinue -Filter "*.config" $serverUNCPath
foreach($config in $configs){
$config_target_dir = $dest.Path + $config.Directory.FullName.Replace($serverUNCPath,"")
if(Test-Path -Path $config_target_dir){
Copy-Item $config -Destination $config_target_dir
}
}
它会失败并显示消息。
Cannot find path 'D:\ServerDeploy\TestMachine1\website\web.config' because it does not exist.
At :line:39 char:12
+ Copy-Item <<<< $config -Destination $config_target_dir
路径D:\ServerDeploy\TestMachine1\website
存在。我对此感到非常沮丧。
我应该怎么做才能解决这个问题?