【发布时间】:2022-01-11 18:20:09
【问题描述】:
我正在尝试将主机名重命名为特定的主机名 - TEAM-CNTNR 使用用户数据脚本,但在 EC2 实例上线并连接到它(通过会话管理器)后,主机名是随机的EC2服务给出EC2AMAZ-VHAGRNV等实例。
这是我的用户数据脚本,我错过了什么吗?这是我的用户数据脚本:
<powershell>
Import-Module ECSTools
[Environment]::SetEnvironmentVariable("ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE", $TRUE, "Machine")
Initialize-ECSAgent -Cluster "${cluster_name}" -EnableTaskIAMRole -LoggingDrivers '["json-file","awslogs"]' -EnableTaskENI
# rename the instance hostname so that it works with the gMSA account
Rename-Computer -NewName "TEAM-CNTNR" -Force
## instance-domain-join code here. Omitted for brevity
# Perform the domain join
Add-Computer -DomainName "$domain_name.$domain_tld" -OUPath "OU=Computers,OU=enrcloud,DC=enr,DC=cloud" -ComputerName "$hostname" -Credential $credential -Passthru -Verbose -Restart
</powershell>
<runAsLocalSystem>true</runAsLocalSystem>
【问题讨论】:
-
VM 是否已加入域?计算机帐户是否已经存在?
-
嗨,是的 - 在我添加主机名更改代码行之前,域加入代码运行良好
标签: amazon-web-services powershell amazon-ec2