Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 从文件夹中的文件夹复制文件_Powershell - Fatal编程技术网

Powershell 从文件夹中的文件夹复制文件

Powershell 从文件夹中的文件夹复制文件,powershell,Powershell,大家好,我想在以下方面得到你们的帮助。我有一个文件夹,其中包含我正在使用powershell安装的一些msi文件。代码如下 Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "VS2010_Runtimes_x86.msi") -ArgumentList '/qb' -Wait 我使用相同的命令安装其余的msi文件。我有一个叫做Project的不同文件夹,它位于原始文件夹中。我想将项目文件夹中的所有文件复制到其

大家好,我想在以下方面得到你们的帮助。我有一个文件夹,其中包含我正在使用powershell安装的一些msi文件。代码如下

Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "VS2010_Runtimes_x86.msi") -ArgumentList '/qb' -Wait
我使用相同的命令安装其余的msi文件。我有一个叫做Project的不同文件夹,它位于原始文件夹中。我想将项目文件夹中的所有文件复制到其他目录

Copy-Item -Path $(Join-Path -Path $PSScriptRoot -ChildPath "Project") -Destination "C:\Program Files (x86)\Hewlett Packard Enterprise\Records Manager" -Recurse
复制文件的代码无效:(

我的全部代码是:

Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "VS2010_Runtimes_x86.msi") -ArgumentList '/qb' -Wait
Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "VS2013_Runtimes_x86.msi") -ArgumentList '/qb' -Wait
Start-Process -FilePath $(Join-Path -Path $PSScriptRoot -ChildPath "HPE_RM_x86.msi") -ArgumentList '/qb' -Wait

Remove-Item 'C:\Users\Public\Desktop\HPE RM Queue Processor.lnk'
Remove-Item 'C:\Users\Public\Desktop\HPE RM Desktop.lnk'

Copy-Item -Path $(Join-Path -Path $PSScriptRoot -ChildPath "Project") -Destination "C:\Program Files (x86)\Hewlett Packard Enterprise\Records Manager" -Recurse

我无法重现错误,您能否使用
-Verbose
开关运行
复制项
,并将输出包含在您的问题中?请详细说明“不工作”。您的代码是否在可以将文件写入
C:\程序文件(x86)子目录的帐户下运行\
?它不复制文件,我收到一条错误消息Join Path:无法将参数绑定到参数“Path”,因为它是空字符串。@是的,我的帐户有权限。我是计算机上的管理员。我会将项目路径解析提取到单独的行中,以便您可以打印并验证
Join Path
的结果是否正确您希望它是(例如,
$projectPath=Join Path-Path$PSScriptRoot-ChildPath“Project”;Write Host“`$projectPath:$projectPath”;Copy Item-Path$projectPath-Destination“…”-递归;显然它是一个空字符串。不知道为什么
连接路径
会在先前调用
启动进程
时起作用,但在传递到
复制项
时不起作用,但这只是需要调试的内容。此外,这些错误详细信息应该添加到问题中。