我正在尝试让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存在。我要为此发疯了。
我能做些什么来修复它?
发布于 2009-09-03 07:22:45
嗯..。好的?
如果我把这行
Copy-Item $config -Destination $config_target_dir使用
Copy-Item $config.FullName $config_target_dir它突然变得神奇起来..。
怎么回事?
https://stackoverflow.com/questions/1371858
复制相似问题