更改windows计算机名
我试图将重命名计算机行添加到CloudFormation脚本中,但它没有做任何事情,我知道我必须在resource stage中使用UserData属性,我看到了一些示例以及AWS CloudFormation文档,但我认为我缺少一些东西,在示例中,它们只是调用PowerShell命令(正如我在下面所做的)它是有效的,但对我来说什么也没做,有人能帮我吗?如果有人有更好的例子,说明它已经起作用了,我会很感激的更改windows计算机名,windows,amazon-web-services,amazon-ec2,amazon-cloudformation,Windows,Amazon Web Services,Amazon Ec2,Amazon Cloudformation,我试图将重命名计算机行添加到CloudFormation脚本中,但它没有做任何事情,我知道我必须在resource stage中使用UserData属性,我看到了一些示例以及AWS CloudFormation文档,但我认为我缺少一些东西,在示例中,它们只是调用PowerShell命令(正如我在下面所做的)它是有效的,但对我来说什么也没做,有人能帮我吗?如果有人有更好的例子,说明它已经起作用了,我会很感激的 "Resources" : { "EC2Ins
"Resources" : {
"EC2InstanceOne":{
"Type":"AWS::EC2::Instance",
"DeletionPolicy" : "Retain",
"Properties":{
"InstanceType":{ "Ref" : "InstanceType" },
"SubnetId": { "Ref" : "MySubnetVM1" },
"SecurityGroupIds":[ { "Ref" : "SGUtilized" } ],
"SecurityGroupIds":[ { "Ref" : "SGUtilized2" } ],
"IamInstanceProfile" : { "Ref" : "RoleName" },
"KeyName": { "Ref" : "ServerKeyName" },
"ImageId":{ "Ref" : "AMIUtilized" },
"BlockDeviceMappings" : [
{
"DeviceName" : "/dev/sda1",
"Ebs" : {
"VolumeType" : "standard",
"DeleteOnTermination" : "false",
"VolumeSize" : "50"
}
}
],
"UserData" : { "Fn::Base64" : { "Fn::Join" : [ "", [
"powershell.exe Rename-Computer -NewName TESTVM01",
"powershell.exe Restart-Computer"
]
]
}
}
}
}
}
谢谢,致以最诚挚的问候。我能够用以下参数替换PowerShell部件来修复它
"<script>\n",
"PowerShell -Command \"& {Rename-Computer -NewName testvm01}\" \n",
"PowerShell -Command \"& {Restart-Computer}\" \n",
"</script>"
“\n”,
“PowerShell-Command\”&{Rename Computer-NewName testvm01}\“\n”,
“PowerShell-命令\”&{重新启动计算机}\“\n”,
""
是否必须将它们添加到?[“\n”、“powershell.exe重命名计算机-新名称TESTVM01”、“powershell.exe重新启动计算机”和“”之间]