【问题标题】:Where to place powershell script in unattend.xml在 unattend.xml 中放置 powershell 脚本的位置
【发布时间】:2019-11-14 10:11:51
【问题描述】:

我目前无法在我拥有的 unattend.xml 文件中运行 powershell 脚本。 powershell 应该安装应用程序,但 xml 文件似乎无法运行脚本的行。

我在使用<FirstLogonCommands><RunSynchronousCommand><SynchronousCommand> 之间来回切换

<FirstLogonCommands>
   <SynchronousCommand wcm:action="add">
    <CommandLine>Powershell -ExecutionPolicy ByPass -File \\deploy\RemoteInstall\WdsClientUnattend\deploySoftware.ps1</CommandLine>
    <Description>Installs software</Description>
    <Order>1</Order>
   </SynchronousCommand>
</FirstLogonCommands>

这个命令应该运行从我们的服务器安装应用程序的 ps1 脚本。

【问题讨论】:

  • “似乎无法运行脚本行”是什么意思?您收到错误消息吗? (记住:我们看不到你的屏幕。)
  • 根据 setuperr 日志,它说它在运行 FirstLogonCommands 时遇到问题。给出的描述是“该设置未在此上下文中定义。”
  • 用你遇到的所有错误更新你的问题。

标签: xml powershell scripting windows-10 unattend-file


【解决方案1】:

我不确定问题是什么,但如果不需要在 autounattend.xml 文件中包含该命令,我建议您尝试将命令放入 \sources\$OEM$\$ $\Setup\Scripts\SetupComplete.cmd 文件。

先用powershell命令制作cmd文件,像这样

PowerShell.exe /W Normal -ExecutionPolicy Bypass ...

然后通过手动运行它来测试它是否正常工作。如果是的话,把它放在上面提到的目录中,然后再次尝试安装windows。

【讨论】:

  • 我希望在 unattend.xml 文件中使用 powerhsell,以便在登录时已经安装了应用程序。 powershell 的工作原理是它不会静默运行 .msi 和 .bat 文件。
  • 无论您放入 SetupComplete.cmd 文件中的任何内容都会在用户登录之前完成。
  • @hextech /W 开关有什么用?
  • /W 代表 -WindowStyle。有效值为 Normal、Minimized、Maximized 和 Hidden。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-20
  • 2023-03-26
  • 2019-03-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多