首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PowerShell: Copy-Item无法找到路径

PowerShell: Copy-Item无法找到路径
EN

Stack Overflow用户
提问于 2009-09-03 07:16:52
回答 1查看 19.6K关注 0票数 6

我正在尝试让PowerShell将文件从远程计算机(在该计算机上,我通过AD具有管理员权限)复制到本地计算机。它在最奇怪的地方失败了。以下是该脚本的一个片段:

代码语言:javascript
复制
    $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
    }
}

失败,并显示以下消息

代码语言:javascript
复制
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存在。我要为此发疯了。

我能做些什么来修复它?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-09-03 07:22:45

嗯..。好的?

如果我把这行

代码语言:javascript
复制
 Copy-Item $config -Destination  $config_target_dir

使用

代码语言:javascript
复制
 Copy-Item $config.FullName $config_target_dir

它突然变得神奇起来..。

怎么回事?

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1371858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档