PowerShell:复制项目找不到路径
我正在尝试让 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
存在。我为此要发疯了。
我能做什么来修复它?
I'm trying to get PowerShell to copy files from a remote computer (on which I have admin rights through AD) to the local computer.
It fails in the strangest place. Here's a snippet of the script:
$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
}
}
It fails with the message
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
The path D:\ServerDeploy\TestMachine1\website
exists. I'm going mad over this.
What can I do to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
呃……好吧?
它替换线
如果我用
,它突然神奇地起作用了......
什么给出了?
Eeeeh.... OK?
If I replaced the line
with
it suddenly magically worked....
What gives?
就我而言,事实证明这是一个区分大小写的问题。我的源路径位于 WSL 中,区分大小写。
In my case, it turns out to be a case sensitivity issue. My source path is in WSL which is case sensitive.