[英]CloudFormation change windows computer name
I'm trying to add the Rename-Computer line into a CloudFormation script but it is not doing anything, I know that I have to use the UserData property inside the resource stage, I see some examples and also the AWS CloudFormation documentation, but I think I'm missing something, in the examples, they just invoke the PowerShell command (As I did below) and it works, but for me is not doing anything, can someone help me with this?我正在尝试将 Rename-Computer 行添加到 CloudFormation 脚本中,但它什么也没做,我知道我必须在资源阶段使用 UserData 属性,我看到了一些示例以及 AWS CloudFormation 文档,但我认为我遗漏了一些东西,在示例中,他们只是调用 PowerShell 命令(正如我在下面所做的那样)并且它有效,但对我来说没有做任何事情,有人可以帮助我吗? If anyone has a better example that it is already working I will appreciate it.如果有人有更好的例子表明它已经在工作,我将不胜感激。
"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"
]
]
}
}
}
}
}
Thanks, best regards.谢谢,最好的问候。
I was able to fix it replacing the PowerShell part with the following parameters我能够修复它用以下参数替换 PowerShell 部分
"<script>\n",
"PowerShell -Command \"& {Rename-Computer -NewName testvm01}\" \n",
"PowerShell -Command \"& {Restart-Computer}\" \n",
"</script>"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.