【问题标题】:AWS creating a Windows server 2016 with software installationAWS 创建带有软件安装的 Windows 服务器 2016
【发布时间】:2019-10-22 05:02:49
【问题描述】:

我正在尝试通过在使用控制台时调用配置的用户数据部分中的一些 powershell 脚本来启动安装了某些软件的 Windows Server 2016。我正在尝试安装 IIS、编码部署代理、dotnet-hosting 和 dotnet core sdk。这是我的脚本

<powershell>  
mkdir install-tools
Install-WindowsFeature Web-Server -IncludeManagementTools
powershell.exe -Command Read-S3Object -BucketName aws-codedeploy-us-east-1/latest -Key codedeploy-agent.msi -File c:\install-tools\codedeploy-agent.msi
Start-Process -Wait -FilePath c:\install-tools\codedeploy-agent.msi -WindowStyle Hidden
powershell -command "& { iwr https://download.visualstudio.microsoft.com/download/pr/bf608208-38aa-4a40-9b71-ae3b251e110a/bc1cecb14f75cc83dcd4bbc3309f7086/dotnet-hosting-3.0.0-win.exe -OutFile  c:\install-tools\dotnet-hosting-3.0.0-win.exe  } "
Start-Process -Wait -FilePath c:\install-tools\dotnet-hosting-3.0.0-win.exe  -WindowStyle Hidden
powershell -command "& { iwr https://download.visualstudio.microsoft.com/download/pr/40c1dd82-671c-4974-919d-ac8a61ef5a91/49ab67c335878f4a5bdd84e14c76708f/dotnet-sdk-2.2.402-win-x64.exe -OutFile  c:\install-tools\dotnet-sdk-2.2.402-win-x64.exe  } "
Start-Process -Wait -FilePath c:\install-tools\dotnet-sdk-2.2.402-win-x64.exe  -WindowStyle Hidden 
</powershell>  

实例启动后,看起来上面脚本中的所有命令都已执行,直到我尝试在此行安装 dotnet 托管 Start-Process -Wait -FilePath c:\install-tools\dotnet-hosting-3.0.0-win.exe -WindowStyle Hidden 似乎这条线失败了,之后的线没有执行。 为什么这条线失败了?

【问题讨论】:

  • 如果您在新的 aws vm 中逐步手动执行脚本会怎样?一切正常?

标签: powershell windows-server-2016 aws-code-deploy


【解决方案1】:

您只是启动 .exe 文件,而没有告诉它需要做什么。如果您在没有 -WindowStyle Hidden 的情况下启动这些命令,您将看到您刚刚启动了安装程序,很可能正在等待有人按下 Next/Intall 按钮。

根据安装程序的不同,它们可能有一些参数,例如 /quit、/q、/silent 或类似的东西。

Start-Process 使用 -ArgumentList 使用这些参数启动进程。

Start-Process -Wait -FilePath c:\install-tools\dotnet-hosting-3.0.0-win.exe -ArgumentList "/quit"  -WindowStyle Hidden

对于大多数允许基于参数的安装的安装文件,它们都有 /help 和/或 /?将为您提供基本信息的论点。对于应该(未经测试)的两个 .exe 文件

/install /quiet /log $PathToInstallLogFile

而 /install 部分很可能是不必要的,因为它通常是默认值,而 /log 用于调试目的。

【讨论】:

  • 如何找出这些安装程序的参数?我也尝试过静默选项,但这也不起作用。
猜你喜欢
  • 1970-01-01
  • 2019-01-28
  • 2020-08-28
  • 1970-01-01
  • 2020-07-31
  • 1970-01-01
  • 2019-12-31
  • 1970-01-01
  • 2018-09-17
相关资源
最近更新 更多