And*_*sen 4 powershell copy-item
我正在尝试让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
}
}
Run Code Online (Sandbox Code Playgroud)
它失败了
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
Run Code Online (Sandbox Code Playgroud)
路径D:\ServerDeploy\TestMachine1\website存在.我为此疯狂.
我该怎么办才能修复它?
Eeeeh ......好吗?
如果我换了线
Copy-Item $config -Destination $config_target_dir
Run Code Online (Sandbox Code Playgroud)
同
Copy-Item $config.FullName $config_target_dir
Run Code Online (Sandbox Code Playgroud)
它突然神奇地工作....
是什么赋予了?
| 归档时间: |
|
| 查看次数: |
15280 次 |
| 最近记录: |