powershell中的copype.cmd脚本

powershell中的copype.cmd脚本,powershell,Powershell,我想从Power shell构建自定义创建Win pe的脚本,我在Internet上找到了示例脚本,但它们不适合我 脚本是: $Architecture = "x86" $env:path = $env:path + "; C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\DandISetEnv.bat; C:\Program Files (x86)\Windows Kits

我想从Power shell构建自定义创建Win pe的脚本,我在Internet上找到了示例脚本,但它们不适合我

脚本是:

$Architecture = "x86"
$env:path = $env:path + "; C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\DandISetEnv.bat; C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\AMD64\DISM;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\AMD64\Imaging;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\AMD64\BCDBoot;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\AMD64\Oscdimg;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\AMD64\Wdsmcast;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\HelpIndexer;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\WSIM;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment;C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Imaging and Configuration Designer\x86;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\; C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\copype.cmd"
$BuildDir = "D:\winpe x86_2"
Write-Host ("Running Copype script please wait...") -Force 'Yellow'
Invoke-Command { copype.cmd $Architecture $BuildDir }
我用Invoke表达式尝试了相同的错误,我用DandISetEnv.bat尝试了,我把它放在了env变量中,但没有成功,我看不出哪里出了问题。以下是错误:

Running Copype script please wait... -Force Yellow
ERROR: The following processor architecture was not found: x86.
Failed!

我在尝试做同样的事情时偶然发现了这个老问题。我设法使它与此功能一起工作:

function Test-CopyPE {
  $peFileDir = "C:\TestCustom\PE_Files"
  $env = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\DandISetEnv.bat" 
  cmd.exe /c """$env"" && copype amd64 $peFileDir"
}
以下是我用来帮助我解决这个问题的一些相关答案:


为什么要将文件名附加到路径中?系统将查找名为
C:\Program Files(x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\DandISetEnv.bat\
C:\Program Files(x86)的文件夹\Windows工具包\10\Assessment and Deployment Kit\Windows预安装环境\copype.cmd\
。感谢回复我该怎么办我不知道我是power shell的新手?但是当我把路径设置为get这个错误,当另一个设置为get错误时,copype.cmd不是comandlet的commant,path环境变量就是搜索路径。这是一个文件夹列表,当当前目录中没有名称正确的可执行文件时,Windows将通过该列表查找可执行文件。这是当您在
C:\
时,即使文件实际位于
C:\Windows\System32\notepad.exe
中,您也能够键入
notepad.exe
并打开记事本的方式<默认情况下,代码>C:\Windows\System32\位于路径中。这不是一个PowerShell概念。这是一个错误。指定文件名在那里不起作用。路径是用于搜索其他文件的文件夹名称列表。我猜您应该先将值分别更改为
C:\Program Files(x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\
C:\Program Files(x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\
,但我不知道需要什么配置
copype.cmd
。我确实再次尝试了erro调用命令:找不到接受参数“D:\winpe\u x86”的位置参数。位于D:\posao\u instalacija\Winpe\u 10\skripte\Test2.ps1:5 char:1+调用命令copype.cmd$Architecture$BuildDir+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~类别信息:InvalidArgument:(:)-Invoke-Command],ParameterBindingException+FullyQualifiederId:ParameterFound,Microsoft.PowerShell.Commands.InvokeCommandCommand