【问题标题】:Userdata: Installing IIS on Windows Server 2016用户数据:在 Windows Server 2016 上安装 IIS
【发布时间】:2018-07-08 20:38:45
【问题描述】:

我正在尝试在 AWS 中编写一个将安装 IIS 的新服务器设置脚本。我试图做到这一点的方式是使用用户数据:

<powershell> 
Start-Transcript; 

# Set Default Password for Testing
net user "Administrator" "Password.1"; 

# Install IIS
Import-Module ServerManager; 
Install-WindowsFeature web-server, web-webserver -IncludeAllSubFeature; 
Install-WindowsFeature web-mgmt-tools; 

# Configure Bindings to :443
New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https -SslFlags 0;
$newCert = New-SelfSignedCertificate -DnsName localhost -CertStoreLocation cert:\LocalMachine\My; 
$SslBinding = Get-WebBinding -Name "Default Web Site" -Protocol "https";
$SslBinding.AddSslCertificate($newCert.GetCertHashString(), "my"); 
Get-WebBinding -Port 80 -Name "Default Web Site" | Remove-WebBinding;

# Install CodeDeploy Agent 
Import-Module AWSPowerShell; 
New-Item -Path "C:\Temp" -ItemType "directory" -Force; 
Read-S3Object -BucketName aws-codedeploy-us-east-1 -Key latest/codedeploy-agent.msi -File c:\temp\codedeploy-agent.msi; 
c:\temp\codedeploy-agent.msi /quiet /l c:\temp\host-agent-install-log.txt;
</powershell>

我的问题似乎是为了真正完成安装,我需要将远程桌面安装到机器中。

鉴于这将在一个自动缩放组中,因此必须将桌面远程连接到服务器中,因为它们正在被启动以满足需求。

为什么我必须远程桌面才能完成脚本? 我是否可以以这样一种方式编写脚本,这意味着我不必在服务器启动时将 RDP 插入服务器?

【问题讨论】:

  • 我已经成功地通过用户数据脚本安装了 IIS,方法是使用带有-NoRestart 标志集的Enable-WindowsOptionalFeature 命令:Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'IIS-WebServerRole', 'IIS-WebServer', 'IIS-ManagementConsole'
  • 谢谢!就这样 - 我已经把它作为答案,以防其他人遇到这个问题
  • 太棒了!很高兴为您提供帮助!

标签: amazon-web-services windows-server windows-server-2016 user-data


【解决方案1】:

我已经成功地通过用户数据脚本安装了 IIS,方法是使用带有 -NoRestart 标志集的 Enable-WindowsOptionalFeature 命令:Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'IIS-WebServerRole', 'IIS-WebServer', 'IIS-ManagementConsole'

【讨论】:

    【解决方案2】:

    感谢以上Adil B。我通过更改功能的安装方式解决了这个问题。新脚本如下所示:

    <powershell> 
    Start-Transcript; 
    
    # Install IIS
    Import-Module ServerManager; 
    Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'IIS-WebServerRole', 'IIS-WebServer', 'IIS-ManagementConsole';
    
    # Configure Bindings to :443
    New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https -SslFlags 0;
    $newCert = New-SelfSignedCertificate -DnsName localhost -CertStoreLocation cert:\LocalMachine\My; 
    $SslBinding = Get-WebBinding -Name "Default Web Site" -Protocol "https";
    $SslBinding.AddSslCertificate($newCert.GetCertHashString(), "my"); 
    Get-WebBinding -Port 80 -Name "Default Web Site" | Remove-WebBinding;
    
    # Install CodeDeploy Agent 
    Import-Module AWSPowerShell; 
    New-Item -Path "C:\Temp" -ItemType "directory" -Force; 
    Read-S3Object -BucketName aws-codedeploy-us-east-1 -Key latest/codedeploy-agent.msi -File c:\temp\codedeploy-agent.msi; 
    c:\temp\codedeploy-agent.msi /quiet /l c:\temp\host-agent-install-log.txt;
    </powershell>
    

    【讨论】:

      猜你喜欢
      • 2017-08-07
      • 2016-08-24
      • 2021-02-11
      • 1970-01-01
      • 1970-01-01
      • 2017-08-07
      • 2021-04-03
      • 1970-01-01
      • 2017-05-09
      相关资源
      最近更新 更多